Smart Client 學習筆記(02):添加工具條按鈕

步驟01:在Infrastructure.Interface項目裏添加引用:

using System.Drawing;

using Infrastructure.Interface.Constants;

步驟02:在WorkItemController.cs裏添加如下方法:   

隱藏行號 複製代碼 在WorkItemController.cs裏添加如下方法:
  • protected void RegisterLaunchPoint(string text, Image icon, string commandName)
    
  •        {
    
  •            var button = new ToolStripButton();
    
  •            button.TextImageRelation = TextImageRelation.ImageAboveText;
    
  •            button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
    
  •            button.ImageScaling = ToolStripItemImageScaling.None;
    
  •            button.Image = icon;
    
  •            button.Text = text;
    
  •            button.ToolTipText = text;
    
  •            WorkItem.Commands[commandName].AddInvoker(button, "Click");
    
  •            WorkItem.UIExtensionSites[UIExtensionSiteNames.LaunchBar].Add(button);
    
  •        }
    

 

步驟03:在自己的Module裏ModuleController下的ExtendToolStrip添加如下代碼:

隱藏行號 複製代碼 添加按鈕:
  • RegisterLaunchPoint( Properties.Resources.ModuleTitle,Properties.Resources.ShippingIcon,CommandNames.ShipOrder);
    

步驟04:添加事件代碼如下代碼:

 

隱藏行號 複製代碼 添加事件:
  • [CommandHandler(CommandNames.ShipOrder)]
    
  •        public void OnshowOrder(object sender,EventArgs e)
    
  •        {
    
  •            MessageBox.Show("Ship Order invoked!");
    
  •        }
    

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章