2011年10月24日 星期一

Facebook WinForm API (3)

測試下載圖片 GraphApiAsyncExample();
1. Ref: http://www.digitalcoding.com/Code-Snippets/C-Sharp/C-Code-Snippet-Download-Image-from-URL.html
1.1 下載網頁圖片
2  用Ref1建立 Class DownloadImageClass, 製作DownloadImage類別方法。
3. 修改  GraphApiAsyncExample()
var fb = new FacebookClient(_accessToken);
            try
            {
                dynamic result = fb.Get("/me");
                var name = result.name;
                lnkName.Text = "Hi " + name;
                lnkName.LinkClicked += (o, e) => Process.Start(result.link);
                // available picture types: square (50x50), small (50xvariable height), large (about 200x variable height) (all size in pixels)
                // for more info visit http://developers.facebook.com/docs/reference/api
                picProfilePic.LoadAsync(string.Format("https://graph.facebook.com/{0}/picture?type={1}", result.id, "square"));
// ----------- 建置image 物件
// ----------- 下載網址圖片
// ----------- 另存圖檔 Test1.jpg
                Image im = null;
                im = DownloadImageClass.DownloadImage(string.Format("https://graph.facebook.com/{0}/picture?type={1}", result.id, "square"));
                im.Save("Test1.jpg");
4. 測試OK!

Facebook WinForm API (2)

1. There are three forms in this example:
1.1 Mainform (start program)
1.2 Browser in a form (login)
1.3 WinForm (Employ api communicate with Facebook server)
2. Test FqlAsyncSample() @  WinForm class
There are serveral testing methods in the constructor
            _accessToken = accessToken;
            InitializeComponent();
            GraphApiAsyncExample();
            LegacyRestApiAsyncExample();
            FqlAsyncSample();
            FqlMultiQueryAsyncSample();
            GraphApiBatchRequestAsyncSample();
            GraphApiExample();
3.  FqlAsyncSample();
 private void FqlAsyncSample()
        {
            var fb = new FacebookClient(_accessToken);
// 非同步語法             fb.QueryAsync(query); @ 最後一行,完成後執行此事件
            fb.GetCompleted +=
                (o, e) =>
                {
                    if (e.Error == null)
                    {
                        var result = (IList<object>)e.GetResultData();
                        var count = result.Count;
                        lblTotalFriends.Text = string.Format("You have {0} friend(s).", count);
                        foreach (dynamic friend in result)
                        {
// friend.屬性 由 SELECT 欄位名稱決定
                            textBox1.Text +=   friend.last_name + friend.first_name +  ": Facebook username: " + friend.username + "\n\n";
                        }
   
                    }
                    else
                    {
                        MessageBox.Show(e.Error.Message);
                    }
                };
            // query to get all the friends
            var query = string.Format("SELECT uid,pic_square, name, last_name, first_name  FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0})", "me()");
            fb.QueryAsync(query);
        }
4. 圖片 pic_square 為url
friend.pic_square
http://profile.ak.fbcdn.net/hprofile-ak-snc4/491XX_560998701_3563_q.jpg

2011年10月22日 星期六

圖形比對(Image matching)

1. Ref: http://briian.com/?p=7224
TinEye 可以用來作為圖形比對。
2. Ref: http://www.tineye.com/search/209759428e73f8572d44b91b861a40f4df7113b9/
提供線上比對tineye資料圖庫
example

3. 似乎有API可以運用。

2011年9月19日 星期一

ASUS TF101 Wiimote

1. ASUS TF101 安裝 WiimoteController 可以操作(取代Mouse)。 2. 觸控螢幕鍵盤失效,需停止WiimoteController, 觸控鍵盤功能可以恢復。

2011年8月30日 星期二

C# Linq (1)

Silverlight application 看來像要運用WCF連接資料庫,先試一下Linq to SQL
工作環境: Windows 7 (x86), VS2010, SQL 2008 R2
1. VS 2010 伺服器管理,連接資料庫
2. 主控台專案,加入新項目(資料 > Linq To SQL 類別) DataClass1.dbml
3. 拖取資料表(Table)進入DataClass1.dbml
4. 記得全部儲存。
5. 測試程式:
static void Main(string[] args)
{
DataClasses1DataContext db = new DataClasses1DataContext();
var ths = (
from us in db.teacher
select new { us.user, us.Email, us.education }).Take(2);
foreach (var t in ths)
{
Console.WriteLine(t.user +"," + t.Email + "," + t.education);
}

}
6.


2011年8月12日 星期五

Server 2008 x64 OleDB

1. 轉移ASP.NET網頁。
2. 系統Server 2008 x64, w/o Office
3. 網頁讀取 Access Database 錯誤 Microsoft.Jet.OLEDB.4.0 提供者並未登錄於本機電腦上。
4. IIS ASP.NET 啟用32位元應用。

Server 2008 IIS (ASP.NET 4.0 尚未在Web 伺服器上註冊)

1. 安裝Server 2008, ASP.NET 網頁無法啟動。
2. VS 2010 檢查顯示: ASP.NET 4.0 尚未在Web 伺服器上註冊
3. Cmd 模式:切換目錄
C:\>cd \WINDOWS\Microsoft.NET\Framework\v4.0.30319
4.註冊
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe /i
開始安裝 ASP.NET (4.0.30319)。
...............
完成安裝 ASP.NET (4.0.30319)。
5.