/// <summary> /// 设置工具栏按钮的界面元素值 /// </summary> /// <param name="Tsb"></param> /// <param name="UIE"></param> protected void SetToolStripComboBoxValue(object ControlObj, IUIElement UIE) { ToolStripComboBox Tsb = (ToolStripComboBox)ControlObj; if (UIE != null) { Tsb.Visible = UIE.IsVisible(); Tsb.Enabled = UIE.IsEnabled(); } int selectindex = -1; foreach (object obj in Tsb.Items) { IToolsItem tt = obj as IToolsItem; if (tt != null) { if (tt.UIElement != null) { if (tt.UIElement.IsActive()) { selectindex = Tsb.Items.IndexOf(obj); } } } } if (selectindex != -1 && Tsb.DroppedDown == false) { Tsb.SelectedIndex = selectindex; } }
/// <summary> /// /// </summary> /// <param name="Tb"></param> /// <returns></returns> protected override System.Windows.Forms.ToolStripItem CreateItem(IToolsItem Tb) { ToolsSeparator item = (ToolsSeparator)Tb; ToolStripItem newItem = new ToolStripSeparator(); //newItem.Name = item.ItemID.ToString(); return(newItem); }
/// <summary> /// /// </summary> /// <param name="Tb"></param> /// <returns></returns> protected override bool IsType(IToolsItem Tb) { if (Lemon.GetObjType(Tb) == typeof(ToolsButton)) { return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <param name="Tb"></param> /// <returns></returns> public ToolStripItem BuildItem(IToolsItem Tb) { if (IsType(Tb)) { return(this.CreateItem(Tb)); } else if (this.nextProcess != null) { return(this.nextProcess.BuildItem(Tb)); } else { return(null); } }
/// <summary> /// 这里判断是否为ui元素 不是则不予创建 /// </summary> /// <param name="Tb"></param> /// <returns></returns> protected override System.Windows.Forms.ToolStripItem CreateItem(IToolsItem Tb) { ToolsButton btn = (ToolsButton)Tb; ToolStripItem newItem = new ToolStripButton(); newItem.Text = btn.Title; if (File.Exists(btn.ItemImage)) { newItem.Image = System.Drawing.Image.FromFile(btn.ItemImage); } //newItem.Name = btn..ToString(); newItem.Tag = Tb; newItem.Click += new EventHandler(BindClickEvent); return(newItem); }
/// <summary> /// 添加工具栏按钮 /// </summary> /// <param name="Btn"></param> public void AddItem(IToolsItem Btn) { var btc = this.btnCols.Find(delegate(IToolsItemCollection bc) { return(bc.CollectionName == Btn.GroupName); }); if (btc != null) { btc.AddButton(Btn); } else { IToolsItemCollection tbc = new ToolBar.ToolsButtonCollection(); tbc.CollectionName = Btn.GroupName; tbc.AddButton(Btn); this.btnCols.Add(tbc); } if (this.EventAddItem != null) { this.EventAddItem(this, Btn); } }
/// <summary> /// /// </summary> /// <param name="Tb"></param> /// <returns></returns> protected abstract ToolStripItem CreateItem(IToolsItem Tb);
/// <summary> /// /// </summary> /// <param name="ItemObj"></param> /// <returns></returns> protected abstract bool IsType(IToolsItem ItemObj);
/// <summary> /// /// </summary> /// <param name="Button"></param> public void AddButton(IToolsItem Button) { this.btns.Add(Button); }