2010年9月18日 星期六

Make WPF Window to Full Screen

Q: How to Make WPF Window to Full Screen ?
A:
 



or set it in Application Resources
 



2010年3月13日 星期六

30 分鐘寫個象棋遊戲(一)

利用 Silverlight 視覺化元件架構,可以很容易的寫些小遊戲(Casual Game),只要熟悉Silverlight 基本概念,花個30分鐘就可以寫個象棋遊戲,不相信嗎? 讓我們試試看吧!

目標:
1. 依物件導向方式設計視覺化元件:棋子、棋盤、計分板
2. 棋面佈局、棋子走法檢查、盤勢分析
3. 人機棋賽(不在本專案範圍)

首先打開 Microsoft Expression Blend,新增一個 Silverlight Application + Web Site 專案,再按下列步驟,設計棋子
1. 在MainPage.xaml內以Ellipse畫個圓,取名為EllipseChess,再放入一個TextBlock,作為棋子上的文字標示,將TextBlock取名為TextBlockChessName
2. 框住圓,MouseDragElementBehavior,Double Click mouse,讓棋子可在畫面上可以用滑鼠移動
3. 框住圓及TextBlock,按滑鼠右鍵,選【Make into UserControl】,將棋子轉換為元件,取名ChessControl.xaml,打開ChessControl.xaml,調整段落至下層,如下:




...






4. 從專案中打開ChessControl.xaml.vb,建立屬性如下:



public property ChessName as String
Get
return TextBlockChessName.Text
end Get
Set(val as String)
TextBlockChessName.Text=val
End Set
end property

public property ChessColor as color
Get
return ctype(EllipseChess.Fill,solidcolorbrush).color
end Get
Set(val as color)
ctype(EllipseChess.Fill,solidcolorbrush).color=val
'EllipseChess.Effect.color=iif(val=colors.black,colors.red,colors.black)
End Set
end property


5. 切換到MainPage.xaml,在Asset視窗內Behavior類別內找到ChessControl,拖曳到畫布中,指定ChessColor 、ChessName ,就可以新增一顆棋子了。

大功告成,按F5執行,就可在畫面看到棋子,並試看看移動棋子,若沒問題,下次就要設計棋盤了。
Keep going.

範例程式


2010年2月4日 星期四

Silverlight 10個有用的快速鍵(Shortcuts)

  1. CTRL+滑鼠滾輪(Mouse Wheel) : 針對游標所在區域放大/縮小
  2. TAB 或 F4 : 最大化設計視窗(Art Board)之切換鍵
  3. F6 : 切換動畫(Animation)與設計(Design)的工作空間
  4. F12 : 顯示/隱藏建置結果(Result)視窗
  5. CTRL+SHIFT+R : 恢復原始的工作空間樣貌
  6. 按住【空白鍵】+ 滑鼠滾輪(Mouse Wheel): 放大或縮小設計視窗(Art Board)
  7. CTRL+0 : 使設計視窗(Art Board)大小符合螢幕大小
  8. CTRL+1 : 使控制項反映真實大小
  9. CTRL+PERIOD (.) : 顯示Asset視窗
  10. F9 : 顯示/隱藏控制項的外框

    原文:http://www.uxpassion.com/2008/09/top-10-useful-shortcuts-in-expression-blend/

2010年1月26日 星期二

Silverlight clipboard and printing testing

Silverlight 4 supports clipboard and printing functions directly, instead of using Windows API.

Regarding to clipboard, Silverlight only provides TEXT copy/paste functions, without IMAGE functions. The usage is as follows:

Clipboard.SetText(TextBox1.Text)


And we could provide the printing function with the following code:

Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf PrintPage
pd.Print()


Sub PrintPage(ByVal s As Object, ByVal e As PrintPageEventArgs)
e.PageVisual = Chart1 ' LayoutRoot
End Sub


PrintPage function is the event handler of printing.

2010年1月25日 星期一

Test SyntaxHighlighter

  
string s = @"aaa";
messageBox.show(s);


 
dim s as string = "aaa"
messageBox.show(s)