private void TreeMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button!=MouseButtons.Right) return; TreeNode node=barTree.GetNodeAt(e.X,e.Y); if(node!=null) barTree.SelectedNode=node; // Popup menu ButtonItem popup=barManager.Items["popup"] as ButtonItem; // If MoveTo and CopyTo are visible add items to them if(popup.SubItems["copyto"].Visible) { BaseItem itemCopyTo=popup.SubItems["copyto"]; BaseItem itemMoveTo=popup.SubItems["moveto"]; BaseItem itemSel=barTree.SelectedNode.Tag as BaseItem; itemCopyTo.SubItems.Clear(); itemMoveTo.SubItems.Clear(); bool bBars=true,bCategories=false, bPopups=false; // Don't show categories for category items... node=barTree.SelectedNode; while(node.Parent!=null) node=node.Parent; if(m_PopupsNode!=null && node!=m_PopupsNode) bPopups=true; if(m_CategoriesNode!=null && node!=m_CategoriesNode) bCategories=true; if(bBars && m_BarsNode!=null) { foreach(TreeNode barNode in m_BarsNode.Nodes) { BaseItem newItem=new ButtonItem(); newItem.Text=barNode.Text; newItem.Tag=barNode; newItem.Click+=new System.EventHandler(this.CopyMoveToClick); itemCopyTo.SubItems.Add(newItem); itemMoveTo.SubItems.Add(newItem.Copy()); } } if(bCategories && m_CategoriesNode!=null) { ButtonItem cat=new ButtonItem("tocategories"); cat.Text="Categories"; cat.BeginGroup=true; cat.Click+=new System.EventHandler(this.CopyMoveToClick); itemCopyTo.SubItems.Add(cat); itemMoveTo.SubItems.Add(cat.Copy()); foreach(TreeNode catNode in m_CategoriesNode.Nodes) { BaseItem newItem=new ButtonItem(); newItem.Text=catNode.Text; newItem.Click+=new System.EventHandler(this.CopyMoveToClick); newItem.Tag="cat"; itemCopyTo.SubItems.Add(newItem); itemMoveTo.SubItems.Add(newItem.Copy()); } } if(bPopups) { BaseItem pi=new ButtonItem("topopups"); pi.BeginGroup=true; pi.Text="Popups"; pi.Click+=new System.EventHandler(this.CopyMoveToClick); itemCopyTo.SubItems.Add(pi); itemMoveTo.SubItems.Add(pi.Copy()); foreach(BaseItem objItem in m_DotNetBar.ContextMenus) { BaseItem newItem=new ButtonItem(); newItem.Text=(objItem.Text=="")?objItem.Name:objItem.Text; newItem.Tag=objItem; newItem.Click+=new System.EventHandler(this.CopyMoveToClick); itemCopyTo.SubItems.Add(newItem); itemMoveTo.SubItems.Add(newItem.Copy()); } } } Point pt=new Point(e.X,e.Y); pt=barTree.PointToScreen(pt); popup.PopupMenu(pt); }
private void AddDotNetBarControls() { if(m_Menu!=null) { m_Menu.RecalcSize(); m_SimpleBar.Size=new Size(groupBox1.ClientRectangle.Width-12,16); m_SimpleBar.RecalcSize(); m_FloatBar.Size=new Size(groupBox1.ClientRectangle.Width,16); m_FloatBar.RecalcSize(); m_PopupBar.Size=new Size(groupBox1.ClientRectangle.Width,24); m_PopupBar.RecalcSize(); return; } m_Menu=new MenuPanel(); m_Menu.PopupMenu=false; m_Menu.Location=new Point(8,135); // Create Simple Toolbar m_SimpleBar=new Bar(); m_SimpleBar.PassiveBar=true; m_SimpleBar.Location=new Point(4,16); m_SimpleBar.ThemeAware=false; m_FloatBar=new Bar(); m_FloatBar.PassiveBar=true; m_FloatBar.Location=new Point(4,46); m_FloatBar.ThemeAware=false; m_PopupBar=new Bar(); m_PopupBar.PassiveBar=true; m_PopupBar.Location=new Point(4,96); m_PopupBar.ThemeAware=false; ButtonItem menuItem=new ButtonItem(); ButtonItem item, item2; Bitmap bmp=null; item=new ButtonItem("new","&New..."); bmp=BarFunctions.LoadBitmap("BarEditorImages.FileNew.bmp"); bmp.MakeTransparent(Color.Magenta); item.Image=bmp; m_SimpleBar.Items.Add(item.Copy()); m_FloatBar.Items.Add(item.Copy()); m_PopupBar.Items.Add(item.Copy()); menuItem.SubItems.Add(item); item=new ButtonItem("open","&Open"); bmp=BarFunctions.LoadBitmap("BarEditorImages.FileOpen.bmp"); bmp.MakeTransparent(Color.Magenta); item.Image=bmp; item2=(ButtonItem)item.Copy(); item2.ButtonStyle=eButtonStyle.ImageAndText; m_SimpleBar.Items.Add(item2); m_FloatBar.Items.Add(item2.Copy()); m_PopupBar.Items.Add(item2.Copy()); menuItem.SubItems.Add(item); item=new ButtonItem("close","&Close"); bmp=BarFunctions.LoadBitmap("BarEditorImages.FileClose.bmp"); bmp.MakeTransparent(Color.Magenta); item.Image=bmp; item2=(ButtonItem)item.Copy(); item2.Checked=true; item2.ButtonStyle=eButtonStyle.ImageAndText; m_SimpleBar.Items.Add(item2); m_PopupBar.Items.Add(item2.Copy()); item2=(ButtonItem)item2.Copy(); item2.Enabled=false; m_FloatBar.Items.Add(item2.Copy()); menuItem.SubItems.Add(item); item=new ButtonItem("open","Add Ne&w Item..."); menuItem.SubItems.Add(item); item=new ButtonItem("open","Add Existin&g Item..."); menuItem.SubItems.Add(item); item=new ButtonItem("opensol","Open Solution..."); item.BeginGroup=true; bmp=BarFunctions.LoadBitmap("BarEditorImages.FileOpenSol.bmp"); bmp.MakeTransparent(Color.Magenta); item.Image=bmp; item2=(ButtonItem)item.Copy(); item2.Enabled=false; m_SimpleBar.Items.Add(item2); m_FloatBar.Items.Add(item2.Copy()); m_PopupBar.Items.Add(item2.Copy()); menuItem.SubItems.Add(item); item=new ButtonItem("open","Close Solution"); bmp=BarFunctions.LoadBitmap("BarEditorImages.FileCloseSol.bmp"); bmp.MakeTransparent(Color.Magenta); item.Image=bmp; item.Enabled=false; menuItem.SubItems.Add(item); m_Menu.ParentItem=menuItem; groupBox1.Controls.Add(m_Menu); m_Menu.RecalcSize(); m_Menu.Show(); //m_SimpleBar.SetBarState(eBarState.Docked); m_SimpleBar.Size=new Size(groupBox1.ClientRectangle.Width,16); m_SimpleBar.GrabHandleStyle=eGrabHandleStyle.StripeFlat; groupBox1.Controls.Add(m_SimpleBar); m_SimpleBar.RecalcSize(); m_SimpleBar.Show(); m_FloatBar.SetBarState(eBarState.Floating); m_FloatBar.Size=new Size(groupBox1.ClientRectangle.Width,16); groupBox1.Controls.Add(m_FloatBar); m_FloatBar.Text="Bar Caption"; m_FloatBar.RecalcSize(); m_FloatBar.Show(); m_PopupBar.SetBarState(eBarState.Popup); m_PopupBar.Size=new Size(groupBox1.ClientRectangle.Width,24); m_PopupBar.PopupWidth=groupBox1.ClientRectangle.Width; groupBox1.Controls.Add(m_PopupBar); m_PopupBar.RecalcSize(); m_PopupBar.Show(); }
private void CreateToolbar() { Bar bar, barToolbar; ButtonItem item, item2, item3, popupmain; ButtonItem popup=new ButtonItem("popup"); barManager.Items.Add(popup); bar=new Bar("Main Menu"); barManager.Bars.Add(bar); bar.MenuBar=true; bar.Stretch=true; barToolbar=new Bar("Item Navigation"); barManager.Bars.Add(barToolbar); // File Menu item=new ButtonItem("file"); item.Text="&File"; item.PopupType=ePopupType.Menu; bar.Items.Add(item); item2=new ButtonItem("open"); item2.Shortcuts.Add(eShortcut.CtrlO); item.SubItems.Add(item2); item2.Text="&Open definition..."; item2.ImageIndex=4; barToolbar.Items.Add(item2.Copy()); item2=new ButtonItem("save"); item2.Shortcuts.Add(eShortcut.CtrlS); item.SubItems.Add(item2); item2.Text="&Save definition..."; item2.ImageIndex=5; barToolbar.Items.Add(item2.Copy()); item2.BeginGroup=true; item2=new ButtonItem("saveas"); item2.Text="&Save definition as..."; item.SubItems.Add(item2); item2=new ButtonItem("loadbar"); item2.Shortcuts.Add(eShortcut.CtrlL); item.SubItems.Add(item2); item2.Text="Load Bar..."; barManager.Items.Add(item2.Copy()); item2.BeginGroup=true; item2.Enabled=true; item2=new ButtonItem("savebaras"); item2.Shortcuts.Add(eShortcut.CtrlD); item.SubItems.Add(item2); item2.Text="Save Bar as..."; barManager.Items.Add(item2.Copy()); item2.Enabled=false; item2=new ButtonItem("close"); item2.Text="&Close Designer"; item2.BeginGroup=true; item.SubItems.Add(item2); // Tools item=new ButtonItem("tools"); item.Text="&Tools"; item.PopupType=ePopupType.Menu; bar.Items.Add(item); item2=new ButtonItem("barscreation","Create Bar"); item.SubItems.Add(item2); popupmain=item2.Copy() as ButtonItem; popup.SubItems.Add(popupmain); if(m_Bar!=null) item2.Visible=false; else if(m_DotNetBar.LeftDockSite==null && m_DotNetBar.RightDockSite==null && m_DotNetBar.TopDockSite==null && m_DotNetBar.BottomDockSite==null) item2.Enabled=false; item3=new ButtonItem("createbar"); item3.Text="&Toolbar"; item2.SubItems.Add(item3); popupmain.SubItems.Add(item3.Copy()); item3=new ButtonItem("createmenubar"); item3.Text="&Menu Bar"; item2.SubItems.Add(item3); popupmain.SubItems.Add(item3.Copy()); item3=new ButtonItem("createstatusbar","&Status Bar"); item2.SubItems.Add(item3); popupmain.SubItems.Add(item3.Copy()); item3=new ButtonItem("createdockwindow","&Dockable Window"); item2.SubItems.Add(item3); popupmain.SubItems.Add(item3.Copy()); item3=new ButtonItem("createtaskpane","&Task Pane"); item2.SubItems.Add(item3); popupmain.SubItems.Add(item3.Copy()); item2=new ButtonItem("buttonitem"); item2.Text="Add &ButtonItem"; item2.BeginGroup=true; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); item2=new ButtonItem("textboxitem"); item2.Text="Add &TextBoxItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); item2=new ButtonItem("comboboxitem"); item2.Text="Add &ComboBoxItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); item2=new ButtonItem("labelitem"); item2.Text="Add &LabelItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); // Progress Bar Item item2=new ButtonItem("progressbaritem"); item2.Tooltip="Displays a progress bar."; item2.Text="Add &ProgressBarItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); item2=new ButtonItem("customizeitem"); item2.BeginGroup=true; item2.Tooltip="Lets end users hide/show Bar items as well as open the Customize dialog."; item2.Text="Add Custo&mizeItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); item2=new ButtonItem("mdiwindowlistitem"); item2.Tooltip="Displays list of MDI Child forms."; item2.Text="Add &MdiWindowListItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); item2=new ButtonItem("controlcontaineritem"); item2.Tooltip="Allows you to host any Control on Bar or Menu-bar."; item2.Text="Add &ControlContainerItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); item2=new ButtonItem("dockcontaineritem"); item2.Tooltip="Helps you create dockable windows."; item2.Text="Add &DockContainerItem"; item.SubItems.Add(item2); popup.SubItems.Add(item2.Copy()); // Pop-up specific items item2=new ButtonItem("copyto"); item2.Text="Copy To"; item2.BeginGroup=true; item2.PopupType=ePopupType.Menu; popup.SubItems.Add(item2); item2=new ButtonItem("moveto"); item2.Text="Move To"; item2.PopupType=ePopupType.Menu; popup.SubItems.Add(item2); item2=new ButtonItem("delselected"); item.SubItems.Add(item2); item2.Text="&Delete Selected Item"; item2.BeginGroup=true; item2.ImageIndex=7; popup.SubItems.Add(item2.Copy()); // Help item=new ButtonItem("help"); item.Text="&Help"; item.PopupType=ePopupType.Menu; bar.Items.Add(item); item2=new ButtonItem("contents"); item2.Text="&Contents..."; item.SubItems.Add(item2); // item2=new ButtonItem("index"); // item2.Text="&Index..."; // item.SubItems.Add(item2); // item2=new ButtonItem("search"); // item2.Text="&Search..."; // item.SubItems.Add(item2); item2=new ButtonItem("about"); item2.Text="&About"; item2.BeginGroup=true; item.SubItems.Add(item2); bar.DockSide=eDockSide.Top; // Create left bar with the item navigation buttons item=new ButtonItem("addnewitems"); barToolbar.Items.Add(item); item.PopupType=ePopupType.Menu; item.ImageIndex=6; item.Text="Create new item"; item.Tooltip="Press to see available items that can be created"; item.BeginGroup=true; item.Enabled=true; item.SubItems.Add(barManager.Items["buttonitem"].Copy()); item.SubItems.Add(barManager.Items["textboxitem"].Copy()); item.SubItems.Add(barManager.Items["comboboxitem"].Copy()); item.SubItems.Add(barManager.Items["customizeitem"].Copy()); item.SubItems.Add(barManager.Items["mdiwindowlistitem"].Copy()); item.SubItems.Add(barManager.Items["controlcontaineritem"].Copy()); item.SubItems.Add(barManager.Items["dockcontaineritem"].Copy()); item.SubItems.Add(barManager.Items["progressbaritem"].Copy()); barToolbar.Items.Add(barManager.Items["delselected"].Copy()); item=new ButtonItem("moveleft"); barToolbar.Items.Add(item); item.ImageIndex=0; item.Text="Move Left"; item.Tooltip="Move selected item left"; item.BeginGroup=true; item.Enabled=false; item.ClickAutoRepeat=true; barManager.Items.Add(item.Copy()); item=new ButtonItem("moveright"); barToolbar.Items.Add(item); item.ImageIndex=1; item.Text="Move Right"; item.Tooltip="Move selected item right"; item.Enabled=false; item.ClickAutoRepeat=true; barManager.Items.Add(item.Copy()); item=new ButtonItem("moveup"); barToolbar.Items.Add(item); item.ImageIndex=2; item.Text="Move Up"; item.Tooltip="Move selected item up"; item.Enabled=false; item.ClickAutoRepeat=true; barManager.Items.Add(item.Copy()); item=new ButtonItem("movedown"); barToolbar.Items.Add(item); item.ImageIndex=3; item.Text="Move Down"; item.Tooltip="Move selected item down"; item.Enabled=false; item.ClickAutoRepeat=true; barManager.Items.Add(item.Copy()); item=new ButtonItem("synccat"); barToolbar.Items.Add(item); item.ImageIndex=8; item.Text="Sync Categories"; item.Tooltip="Recreates Categories from your current definition."; item.Enabled=true; item.ButtonStyle=eButtonStyle.ImageAndText; item.ClickAutoRepeat=false; barToolbar.DockLine=1; barToolbar.DockSide=eDockSide.Top; popup=new ButtonItem("resetimagepopup"); item=new ButtonItem("resetimage","Reset"); popup.SubItems.Add(item); barManager.ContextMenus.Add(popup); barManager.Style=eDotNetBarStyle.Office2003; }