Public Class Panel_Hello Private Sub Panel_Hello_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.Clear() End Sub
Private Sub ToolStripMenuItem_Hello_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem_Hello.Click TextBox1.Text = "Hello Windows Home Server" End Sub End Class
Private nPanel As Panel_Hello <--在建構函式中會將其設定為Panel_Hello的執行個體參考指標
(3-2) 然後要建立一個建構函式
Sub New(ByVal width As Integer, ByVal height As Integer, ByVal consoleServices As IConsoleServices) nPanel = New Panel_Hello nPanel.Size = New Size(width, height) End Sub
參數說明:
參數一是傳入工作區面板的寬度。 參數二是傳入工作區面板的高度。 參數三是傳入一組可以用來處理與Windows Home Server 程序的一些相關服務(參閱 IConsoleServices Interface ),未來有機會再來談這個Interface。
Public Function GetHelp() As Boolean Implements Microsoft.HomeServer.Extensibility.IConsoleTab.GetHelp MessageBox.Show("Hello Help!") Return True End Function
Public ReadOnly Property SettingsGuid() As System.Guid Implements Microsoft.HomeServer.Extensibility.IConsoleTab.SettingsGuid Get Return Guid.Empty End Get End Property
(3-5)實作 TabControl 屬性,回傳我們所要顯示在工作區面板的控制項。
Public ReadOnly Property TabControl() As System.Windows.Forms.Control Implements Microsoft.HomeServer.Extensibility.IConsoleTab.TabControl Get Return nPanel End Get End Property
Public ReadOnly Property TabImage() As System.Drawing.Bitmap Implements Microsoft.HomeServer.Extensibility.IConsoleTab.TabImage Get Return My.Resources.WHSResource.Hello2 End Get End Property
Public ReadOnly Property TabText() As String Implements Microsoft.HomeServer.Extensibility.IConsoleTab.TabText Get Return "Hello WHS!" End Get End Property
整個範例程式的撰寫到這邊就算告一段落,不過要實際安裝到Windows Home Server裡,還有一些其它的程序要處理,這個我們下一篇再來解說。這個範例可以在以下連結下載 HelloWHS.zip