public virtual void Invalidate() { ToolBoxTab parentTab = _parentItem as ToolBoxTab; Rectangle rcTemp = Rectangle.Empty; if (null != _parent && !_rectangle.IsEmpty) { if (null != parentTab) { rcTemp = _rectangle; rcTemp.Y += parentTab.ItemArea.Y; rcTemp.Inflate(+1, +1); if (rcTemp.Bottom > parentTab.ItemArea.Bottom) { rcTemp.Height = parentTab.ItemArea.Bottom - rcTemp.Top; } _parent.Invalidate(rcTemp); } else { _parent.Invalidate(_rectangle); } } }
/// <summary> /// This method adds a Toolbox item by DTE automation model /// </summary> private void AddItemByDTE() { // Get tabs from automation model ToolBoxTabs tabs = _applicationObject.ToolWindows.ToolBox.ToolBoxTabs; IEnumerator e = tabs.GetEnumerator(); ToolBoxTab tab = null; while (e.MoveNext()) { ToolBoxTab ct = e.Current as ToolBoxTab; if (ct.Name == "CustomTab") { tab = ct; break; } } // If there is no CustomTab, add one if (tab == null) tab = tabs.Add("CustomTab"); // Add Toolbox Item, but we can't customize other information for // Toolbox item like icon and transparency. tab.ToolBoxItems.Add( "DTE Added HTML Content", "<input id=\"Button1\" type=\"button\" value=\"button\" />", vsToolBoxItemFormat.vsToolBoxItemFormatHTML); }
public virtual bool HitTest(int x, int y) { bool bHit = false; ToolBoxTab parentTab = _parentItem as ToolBoxTab; Rectangle rcTemp = Rectangle.Empty; bHit = false; if (null != parentTab) { rcTemp = _rectangle; rcTemp.X += parentTab.ItemArea.X; rcTemp.Y += parentTab.ItemArea.Y; if (rcTemp.Bottom >= parentTab.ItemArea.Bottom - 0) { rcTemp.Height = (parentTab.ItemArea.Bottom - 0) - rcTemp.Top; } bHit = rcTemp.Contains(x, y); } else { bHit = _rectangle.Contains(x, y); } return(bHit); }
// mainfrm.drawToolWindow.OpenOneForm(no.Name); private void ToolBox_TabMouseUp(ToolBoxTab sender, MouseEventArgs e) { Point ptPos = Point.Empty; ContextMenu cm = null; if (e.Button == MouseButtons.Right) { ptPos.X = e.X; ptPos.Y = e.Y; cm = CreateContextMenu(true, sender); cm.Show(this.ToolBox, ptPos); } }
public void AddTool(ICommand cmd) { var command = cmd as SchemaEditor.SchemaCommands.ToolCommand; if (command == null) { return; } _toolBox.ItemSelectionChanged -= new ItemSelectionChangedHandler(ToolChanged); _toolBox.TabSelectionChanged -= new TabSelectionChangedHandler(ToolChanged); var imgnum = 0; ToolBoxTab tbt; if ((tbt = _toolBox[command.ToolGroup]) == null) { tbt = new ToolBoxTab(command.ToolGroup, -1); _toolBox.AddTab(tbt); } _toolBox.SmallImageList.Images.Add(command.ToolIcon); var tbi = new ToolBoxItem(command.ToolName, _toolBox.SmallImageList.Images.Count - 1); tbt.AddItem(tbi); tbi.Object = command; _toolBox.ItemSelectionChanged += new ItemSelectionChangedHandler(ToolChanged); _toolBox.TabSelectionChanged += new TabSelectionChangedHandler(ToolChanged); /*for (int i = 0; i < _toolBox.Tabs.Count; i++) * for (int j = 0; j < _toolBox.Tabs[i].ItemCount; j++) * if (((SchemaEditor.SchemaCommands.ToolCommand)_toolBox.Tabs[i][j].Object).IsActive) * { * _toolBox.Tabs[i].Selected = true; * _toolBox.Tabs[i][j].Selected = true; * _toolBox.Tabs[i].SelectedItem = _toolBox.Tabs[i][j]; * } * else * { * _toolBox.Tabs[i].Selected = false; * _toolBox.Tabs[i][j].Selected = false; * } */ _toolBox.Update(); }
public MainForm() { InitializeComponent(); //填写状态栏信息 toolStripStatusLabel.Text = "已登陆"; toolStripStatususeridtext.Text = Pubvar.gu8userdata.UserId; toolStripStatuscompanytext.Text = "[" + Pubvar.gu8userdata.AccID + "]" + Pubvar.gu8userdata.AccName; toolStripStatusoperationdatetext.Text = Pubvar.gu8userdata.operDate; //构建左侧菜单栏并设置基本属性 u8toolBox.BackColor = System.Drawing.SystemColors.Control; u8toolBox.Dock = System.Windows.Forms.DockStyle.Fill; u8toolBox.TabHeight = 18; u8toolBox.ItemHeight = 20; u8toolBox.ItemSpacing = 1; u8toolBox.ItemHoverColor = System.Drawing.Color.OldLace; u8toolBox.ItemNormalColor = System.Drawing.SystemColors.Control; u8toolBox.ItemSelectedColor = System.Drawing.Color.BurlyWood; //创建tab菜单项 -- U8数据接口 ToolBoxTab _tab_u8datainterface = new ToolBoxTab("U8数据接口", 1); _tab_u8datainterface.SmallImageIndex = 2; u8toolBox.AddTab(_tab_u8datainterface); //创建tab菜单项下子菜单项 -- U8数据接口 -- 数据导入 ToolBoxItem _itemdataimport = new ToolBoxItem(); _itemdataimport.Caption = "数据导入"; _itemdataimport.Enabled = true; _itemdataimport.AllowDrag = false; _itemdataimport.SmallImageIndex = 1; _itemdataimport.Object = new Rectangle(10, 10, 100, 100); u8toolBox[0].AddItem(_itemdataimport); _itemdataimport.Selected = false; //隐藏tab control 及标签页 U8tabCtl.Visible = false; U8dataimporttabPage.Parent = null; }
public void TreeBoxInit() { ToolBoxTabCollection tabCollection = new ToolBoxTabCollection(); //增加tab for (int i = 0; i < TabName.Count(); i++) { this.treeBox.AddTab(TabName[i], 1); ToolBoxTab tab = this.treeBox[i]; tabCollection.Add(tab); } treeView = new TreeView(); treeView.BorderStyle = BorderStyle.None; treeView.Dock = DockStyle.Fill; treeView.ImageList = imageList1; for (int i = 0; i < deType.Count(); i++) { FillTreeView(treeView, deType[i], i); this.treeBox[0].Control = treeView; } treeView1 = new TreeView(); treeView1.BorderStyle = BorderStyle.None; treeView1.Dock = DockStyle.Fill; treeView1.ImageList = imageList1; for (int i = 0; i < reType.Count(); i++) { FillTreeView(treeView1, reType[i], i); this.treeBox[1].Control = treeView1; } }
private ContextMenu CreateContextMenu(bool forTab, ToolBoxItem item) { ToolBoxTab theTab = null; ContextMenu cm = new ContextMenu(); cm.MenuItems.Add(forTab ? "ToolBox Tab Menu" : "ToolBox Item Menu"); cm.MenuItems.Add(item.Caption); cm.MenuItems.Add("-"); cm.MenuItems.Add("Rename " + (forTab ? "Tab" : "Item")); //3 - Rename cm.MenuItems.Add("Move " + (forTab ? "Tab" : "Item") + " up"); //4 - Move up cm.MenuItems.Add("Move " + (forTab ? "Tab" : "Item") + " down"); //5 - Move down cm.MenuItems.Add("Delete " + (forTab ? "Tab" : "Item")); //6 - Delete cm.MenuItems[0].Enabled = false; if (forTab) { theTab = (ToolBoxTab)item; } else { theTab = (ToolBoxTab)item.ParentItem; } cm.MenuItems[3].Enabled = item.Renamable; cm.MenuItems[4].Enabled = item.CanMoveUp; cm.MenuItems[5].Enabled = item.CanMoveDown; cm.MenuItems[6].Enabled = item.Deletable; if (!forTab) { // cm.MenuItems[3].Click += new EventHandler(OnItemRenameClick); // cm.MenuItems[4].Click += new EventHandler(OnItemMoveUpClick); // cm.MenuItems[5].Click += new EventHandler(OnItemMoveDownClick); // cm.MenuItems[6].Click += new EventHandler(OnItemDeleteClick); } else { // cm.MenuItems[3].Click += new EventHandler(OnTabRenameClick); // cm.MenuItems[4].Click += new EventHandler(OnTabMoveUpClick); // cm.MenuItems[5].Click += new EventHandler(OnTabMoveDownClick); // cm.MenuItems[6].Click += new EventHandler(OnTabDeleteClick); } if (!forTab) { editedItem = item; } else { } if (null != theTab) { MenuItem[] subMenus = new MenuItem[3]; subMenus[0] = new MenuItem("List"); subMenus[1] = new MenuItem("Small Icons"); subMenus[2] = new MenuItem("Large Icons"); cm.MenuItems.Add("-"); cm.MenuItems.Add("View", subMenus); switch (theTab.View) { case ViewMode.List: subMenus[0].Checked = true; break; case ViewMode.SmallIcons: subMenus[1].Checked = true; break; case ViewMode.LargeIcons: subMenus[2].Checked = true; break; } subMenus[0].Click += new EventHandler(OnItemViewModeChange); subMenus[1].Click += new EventHandler(OnItemViewModeChange); subMenus[2].Click += new EventHandler(OnItemViewModeChange); } editedTab = theTab; cm.MenuItems.Add("-"); cm.MenuItems.Add("Sample Menu Item 1"); cm.MenuItems.Add("Sample Menu Item 2"); return(cm); }
public void init() { this.ToolBox.TabMouseUp += new TabMouseEventHandler(ToolBox_TabMouseUp); //组件类型 ToolBoxTabCollection tabCollection = new ToolBoxTabCollection(); ToolBoxItemCollection itemCollection = new ToolBoxItemCollection(); for (int i = 0; i < CTabNameStrings.Count(); i++) { this.ToolBox.AddTab(CTabNameStrings[i], 1); ToolBoxTab tab = this.ToolBox[i]; tabCollection.Add(tab); } //自定义控件处理:xuehaouan 2016-4-13 -> string nodeString = "Components/AddedComponent";//注意这里AddedComponent作为与原先的区别 XmlNodeList tmpXNodeLst = mXDoc.SelectNodes(nodeString); XmlNode m_tmpXNode; IEnumerator tmpIe = tmpXNodeLst.GetEnumerator(); List <string> dllFailList = new List <string>(); while (tmpIe.MoveNext()) { m_tmpXNode = tmpIe.Current as XmlNode; string ModName = m_tmpXNode.Attributes["FullName"].Value; string AsmStr = m_tmpXNode.Attributes["Asm"].Value; Assembly assembly; Type type = null; if (AsmStr.Substring(AsmStr.Length - 3) == "dll" || AsmStr.Substring(AsmStr.Length - 3) == "DLL") { if (File.Exists(@dllmng.DLLPATH + AsmStr)) { assembly = Assembly.LoadFile(dllmng.DLLPATH + AsmStr); type = assembly.GetType(AsmStr.Substring(0, AsmStr.Length - 3) + ModName); //类名称 e.g. ACMV.Controls.PIDControlPanelWithDataConn } else { if (!dllFailList.Contains("Can not find DLL: " + AsmStr + " in file " + dllmng.DLLPATH)) { dllFailList.Add("Can not find DLL: " + AsmStr + " in file " + dllmng.DLLPATH); } //MessageBox.Show("Can not find" + AsmStr + " in file " + dllmng.DLLPATH, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (File.Exists(@dllmng.DLLPATH + AsmStr + ".dll")) { assembly = Assembly.LoadFile(dllmng.DLLPATH + AsmStr + ".dll"); type = assembly.GetType(AsmStr + "." + ModName); //类名称 e.g. ACMV.Controls.PIDControlPanelWithDataConn } else { if (!dllFailList.Contains("Can not find DLL: " + AsmStr + ".dll" + " in file " + dllmng.DLLPATH)) { dllFailList.Add("Can not find DLL: " + AsmStr + ".dll" + " in file " + dllmng.DLLPATH); } //MessageBox.Show("Can not find" + AsmStr + ".dll " + " in file " + dllmng.DLLPATH, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (type != null) { System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(type); tabCollection[tabCollection.Count - 1].AddItem(tbi.DisplayName, 2, true, tbi); } } string infoStr = ""; foreach (string dllFail in dllFailList) { infoStr += dllFail + "\r\n"; } if (infoStr != "") { MessageBox.Show(infoStr + "\r\n" + "Please Check!", "Custom Control(DLL) Error Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } //<- if (null != tabCollection) { for (int i = 0; i < moduleType.Count(); i++) { FillTreeView(bnTreeView, moduleType[i], i); tabCollection[0].Control = bnTreeView; } // } for (int i = 0; i < SubModuleTypes.Count(); i++) { System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(SubModuleTypes[i]); tabCollection[1].AddItem(tbi.DisplayName, 3, true, tbi); } } }
/// <summary> /// Activate an item in the toolbox /// </summary> /// <param name="DTE">DTE object</param> /// <param name="tabName">The toolbox tab name</param> /// <param name="itemName">The item name in that tab</param> /// <returns>true if the item has been activated</returns> public static bool ActivateToolboxItem(DTE2 DTE, string tabName, string itemName) { DTE.ExecuteCommand("View.Toolbox", ""); ToolBox toolbox = DTE.ToolWindows.ToolBox; ToolBoxTab tab = toolbox.ToolBoxTabs.Item(tabName); if (tab != null) { tab.Activate(); ToolBoxItem foundItem = null; int foundItemIndex = -1; int selectedItemIndex = -1; ToolBoxItems items = tab.ToolBoxItems; ToolBoxItem selectedItem = items.SelectedItem; foreach (ToolBoxItem currentItem in items) { if (foundItem == null) { ++foundItemIndex; if (currentItem.Name == itemName) { foundItem = currentItem; if (selectedItem == null) { break; } } } if (selectedItem != null) { ++selectedItemIndex; if (selectedItem == currentItem) { selectedItem = null; if (foundItem != null) { break; } } } } if (foundItem != null) { int distance = foundItemIndex - selectedItemIndex; if (distance != 0) { SendKeys.Flush(); if (distance > 0) { SendKeys.SendWait(string.Format("{{DOWN {0}}}", distance)); } else { SendKeys.SendWait(string.Format("{{UP {0}}}", -distance)); } } return(true); } } return(false); }
public bool Contains(ToolBoxTab tab) { return(this.InnerList.Contains(tab)); }
public int IndexOf(ToolBoxTab tab) { return(this.InnerList.IndexOf(tab)); }
public void Remove(ToolBoxTab tab) { this.InnerList.Remove(tab); }
public void Insert(int index, ToolBoxTab tab) { this.InnerList.Insert(index, tab); }
public int Add(ToolBoxTab tab) { return(this.InnerList.Add(tab)); }
public void Remove(ToolBoxTab tab) { base.InnerList.Remove(tab); }