Esempio n. 1
0
		/// <summary>
		/// build (or rebuild) the toolbar
		/// </summary>
		/// <param name="group"></param>
		/// <param name="toolbar"></param>
		private void FillToolbar(ChoiceGroup group, Bar toolbar)
		{
			bool wantsSeparatorBefore = false;
			string groupName =group.Label;

			ClearOutToolbar(toolbar);
			foreach(ChoiceRelatedClass item  in group)
			{
				string itemName =item.Label;
				if(item is SeparatorChoice)
					wantsSeparatorBefore = true;
				else if(item is ChoiceBase)
				{
					ChoiceBase choice = (ChoiceBase) item;
					UIItemDisplayProperties display = choice.GetDisplayProperties();

					if (!display.Visible)
						continue;
					ButtonItem btn = CreateButtonItem(choice, wantsSeparatorBefore);
					btn.Enabled = display.Enabled;
					btn.Category = group.Label;
					toolbar.Items.Add(btn);
					// DIDN'T WORK
					//					if(!Manager.Items.Contains(btn.Name))
					//							Manager.Items.Add(btn.Copy());
					wantsSeparatorBefore = false;
				}
				else if(item is ChoiceGroup) // Submenu
				{
					ChoiceGroup choiceGroup = (ChoiceGroup)item;

					//nb: the DNB class name, "ComboBoxItem" is very misleading. This is the box itself,
					//not an item in the box.
					ComboBoxItem combo = new ComboBoxItem(/*name*/item.Id,/*text*/item.Label);
					toolbar.Items.Add(combo);
					combo.Tag = item;
					int width = 100;
					// Make this configurable from the xml
					XmlAttribute att = item.ConfigurationNode.Attributes["width"];
					if (att != null)
						width = Int32.Parse(att.Value);
					combo.ComboWidth = width;
					//combo.Stretch = true;//doesn't help

					item.ReferenceWidget = combo;
					//submenu.IsEnabled= true;
					//the drop down the event seems to be ignored by the submenusof this package.
					//submenu.DropDown += new System.EventHandler(((ChoiceGroup)item).OnDisplay);
					//therefore, we need to populate the submenu right now and not wait
					choiceGroup.OnDisplay(m_window, null);

					//hide if no sub items were added

					//submenu.Visible = submenu.SubItems.Count>0;
				}
				else
				{
					// TODO: Add support for other types of toolbar objects.
				}
			}
			toolbar.RecalcLayout();
			toolbar.RecalcSize();
		}
Esempio n. 2
0
		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();
		}
Esempio n. 3
0
		/// <summary>
		/// Displays the sub-items on popup toolbar.
		/// </summary>
		/// <param name="x">Horizontal coordinate in pixels of the upper left corner of a popup.</param>
		/// <param name="y">Vertical coordinate in pixels of the upper left corner of a popup.</param>
		public virtual void PopupBar(int x, int y)
		{
			//DotNetBarManager owner=this.GetOwner();
			IOwnerMenuSupport ownerMenu=this.GetIOwnerMenuSupport();
			//if(ownerMenu==null)
			//	throw(new InvalidOperationException("Current owner is not assigned or it does not have popup bar support."));

			System.Windows.Forms.Control objCtrl=this.ContainerControl as System.Windows.Forms.Control;

			if(ownerMenu!=null)
			{
				PopupOpenEventArgs args=new PopupOpenEventArgs();
				if(PopupOpen!=null)
					PopupOpen(this,args);
				if(!args.Cancel)
					ownerMenu.InvokePopupOpen(this,args);
				if(args.Cancel)
				{
					this.Expanded=false;
					return;
				}
			}

			foreach(BaseItem objItem in this.SubItems)
				objItem.Orientation=eOrientation.Horizontal;

			if(m_PopupBar==null)
			{
				m_PopupBar=new Bar();

				if(m_PopupFont!=null)
					m_PopupBar.Font=m_PopupFont;
				else if(objCtrl!=null && objCtrl.Font!=null)
					m_PopupBar.Font=(System.Drawing.Font)objCtrl.Font.Clone();
				if(objCtrl is Bar && ((Bar)objCtrl).ColorScheme!=null)
					m_PopupBar.ColorScheme=((Bar)objCtrl).ColorScheme;
				else if(objCtrl is MenuPanel && ((MenuPanel)objCtrl).ColorScheme!=null)
					m_PopupBar.ColorScheme=((MenuPanel)objCtrl).ColorScheme;
                else if (objCtrl is ItemControl && ((ItemControl)objCtrl).ColorScheme != null)
                    m_PopupBar.ColorScheme = ((ItemControl)objCtrl).ColorScheme;
                else if (objCtrl is ButtonX && ((ButtonX)objCtrl).ColorScheme != null)
                    m_PopupBar.ColorScheme = ((ButtonX)objCtrl).ColorScheme;
				else
                    m_PopupBar.ColorScheme = new ColorScheme(this.EffectiveStyle);
				m_PopupBar.SetBarState(eBarState.Popup);
				m_PopupBar.PopupAnimation=m_PopupAnimation;
				m_PopupBar.Owner=this.GetOwner();
				m_PopupBar.ParentItem=this;
                if(objCtrl!=null)
                    m_PopupBar.RightToLeft = objCtrl.RightToLeft;
				m_PopupBar.CreateControl();
				m_PopupBar.SetDesignMode(this.DesignMode);
				m_PopupBar.ThemeAware=this.ThemeAware;
				
				if(objCtrl is IBarImageSize)
					m_PopupBar.ImageSize=((IBarImageSize)objCtrl).ImageSize;					

				m_PopupBar.PopupWidth=m_PopupWidth;

				m_PopupBar.RecalcSize();
			}

			// Make sure that menu is on-screen
			ScreenInformation objScreen=null;
			if(IsHandleValid(objCtrl))
			{
				objScreen=BarFunctions.ScreenFromControl(objCtrl);
			}
			else
			{
				objScreen=BarFunctions.ScreenFromPoint(new Point(x,y));
			}

			if(this.IsRightHanded)
				x-=m_PopupBar.Width;

			if(objScreen!=null && x+m_PopupBar.Width>objScreen.WorkingArea.Right)
			{
				// Push it to the right side
				x=objScreen.WorkingArea.Right-m_PopupBar.Width;
			}
			else if(objScreen!=null && x<objScreen.WorkingArea.Left)
				x=objScreen.WorkingArea.Left;

			// Try to fit whole popup menu "nicely"
			if(objScreen!=null && y+m_PopupBar.Height>objScreen.WorkingArea.Bottom)
			{
				// If this container is displayed then try to put it above the menu item
				if(this.Displayed && objCtrl!=null)
				{
					Point p=new Point(m_Rect.Left,m_Rect.Bottom), ps;
					ps=objCtrl.PointToScreen(p);
					ps.Y+=2;
					if(ps.Y-m_PopupBar.Height>=objScreen.WorkingArea.Top)
						y=ps.Y-m_PopupBar.Height;
				}
			}

            x += _PopupOffset.X;
            y += _PopupOffset.Y;

			// If it still does not fit at this point, container will scale itself properly
			// And allow item scrolling
			m_PopupBar.Location=new Point(x,y);
			if(ownerMenu!=null)
				ownerMenu.InvokePopupShowing(this,new EventArgs());
			m_PopupBar.ShowBar();
			this.Expanded=true;
			
			if(ownerMenu!=null)
			{
				if(!(objCtrl is Bar) && !(objCtrl is MenuPanel))
				{
					ownerMenu.RegisterPopup(this);
					m_FilterInstalled=true;
				}
				else if(objCtrl is Bar)
				{
					Bar bar=objCtrl as Bar;
					if(bar.BarState!=eBarState.Popup)
					{
						ownerMenu.RegisterPopup(this);
						m_FilterInstalled=true;
					}		
					bar=null;
				}
			}
		}