2011年6月16日 星期四

Microsoft Technology Associate (MTA) 新認證

即將發佈的新認證- MTA 。

看起來像是IT、程設與資料庫的基礎考試。

對象是學生、教師、學校的IT人員

底下資料來自微軟網站,參考 http://www.microsoft.com/learning/en/us/certification/mta.aspx

 

image

2011年6月14日 星期二

在WPF應用程式自訂Command

1.在WPF應用程式中加入一個類別
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace WpfApplication1 {
public class UICommands {
        public static RoutedUICommand ChangeBGColorCommand =
            new RoutedUICommand ( );
    }
}
2.在XAML Window 中加入命名空間
xmlns:cmd="clr-namespace:WpfApplication1"
image
3.加Window.CommandBindings
<Window.CommandBindings>
       <CommandBinding x:Name="changebg"  Executed="changebg_Executed"
                        Command="cmd:UICommands.ChangeBGColorCommand"
                       />
   </Window.CommandBindings>
image
4.寫changebg_Executed 事件
private void changebg_Executed ( object sender , ExecutedRoutedEventArgs e ) {
           this.button1.Background = new SolidColorBrush ( Colors.Red );
       }
image
5.在Window加入StackPanel 、Menu、MenuItem 、Button
<StackPanel >
        <Menu>
            <MenuItem Header="_Menu" >
                <MenuItem Header="Change "  
                          Command="cmd:UICommands.ChangeBGColorCommand"
                 />
             
            </MenuItem>
        </Menu>
        <Button Content="Button" Height="23" Name="button1" Width="75" />
    </StackPanel>
image
6.Run
image

2011年6月8日 星期三

在WPF Application設定Splash Screen

在WPF Application設定Splash Screen的動作很簡單,先加一張圖片到WPF Application,然後將Build Action設定為SplashScreen就可以了。

image

2011年5月16日 星期一

在VS2010 SP1專案中使用IIS 7.5 Express

Visual Studio 2010中使用File System方式建立Web Site或透過專案方式建立Web Application預設都會使用ASP.NET Development Server來執行網站程式,它相當於IIS 6.0的精簡版。若要使用到IIS 7.5的新功能,現在除了將網站建立在真正IIS 7.5上,還有另一個選擇,便是使用IIS 7.5 Express版。
首先你需要先到http://www.microsoft.com/web/gallery/install.aspx?appid=iisexpress下載IIS 7.5 Express,然後安裝:
image
安裝畫面;
image
完成後可以選擇安裝其它額外的功能。
image
以後在Visual Studio 2010 建立Web Site或Web Application時就可以選取要使用IIS 7.5 Express來執行;
image
Visual Studio會詢問是否要使用IIS 7.5 Express;
image
然後轉換
image
以後在工作列下方就可以看到IIS Express的小圖示,
image
在Visual Studio 2010專案屬性視窗下方也可以進階去設定驗證方式,要不要使用SSL等等功能
image
你也可以在Visual Studio 2010 的Tools->Options中設定未來的網站程式,會優先使用IIS 7.5 Express來執行
image

2011年4月19日 星期二

Q&A 從WCF回傳ArrayList與自訂型別

收到李先生問題如下:
Q :
我的 WCF Service 需回傳 ArrayList,
若 ArrayList 只內含一些 string, 程式可 work,
但 ArrayList 若內含一些 Custom Class 就不 work,
請問老師問題出在那兒 ?
A:
善用DataContract與ServiceKnownType Attribute就可以囉~
例如Service Contract為:
[ServiceContract]
public interface IService {
    [OperationContract]
   [ServiceKnownType ( typeof ( CompositeType ) )]     ArrayList GetData ( );
}
[DataContract] public class CompositeType {
    bool boolValue = true;
    string stringValue = "Hello ";
    [DataMember]
    public bool BoolValue {
        get { return boolValue; }
        set { boolValue = value; }
    }
    [DataMember]
    public string StringValue {
        get { return stringValue; }
        set { stringValue = value; }
    }
}
服務:
public class Service : IService {
    public ArrayList GetData ( ) {
        ArrayList ar = new ArrayList ( );
        CompositeType c = new CompositeType ( );
        c.StringValue = "aaa";
        ar.Add ( c );
        return ar;
    }
}
產生Proxy 時要設
image
Client
ServiceReference1.ServiceClient c = new ServiceReference1.ServiceClient ( );
ArrayList ar = ( ArrayList ) c.GetData (  );
Console.WriteLine ( (( CompositeType ) ar [ 0 ]).StringValue.ToString() );

總網頁瀏覽量