예제 #1
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();
		}
예제 #2
0
		/// <summary>
		/// Creates new instance of PopupItem and assigns the name and text to it.
		/// </summary>
		/// <param name="sName">Item name.</param>
		/// <param name="ItemText">Item text.</param>
		public PopupItem(string sName, string ItemText):base(sName, ItemText)
		{
			m_PopupMenu=null;
			m_PopupBar=null;
			m_FilterInstalled=false;
			m_PopupType=ePopupType.Menu;
			m_SideBar=new SideBarImage();
			m_WasParentFocused=false;
			m_OldSubItemsImageSize=Size.Empty;
		}
예제 #3
0
		/// <summary>
		/// Closes the currently open popup.
		/// </summary>
		public virtual void ClosePopup()
		{
			if(m_OldSubItemsImageSize!=Size.Empty)
			{
				this.SubItemsImageSize=m_OldSubItemsImageSize;
				m_OldSubItemsImageSize=Size.Empty;
			}

			//DotNetBarManager owner=this.GetOwner();
			IOwnerMenuSupport ownerMenu=this.GetIOwnerMenuSupport();

			if(ownerMenu!=null)
				ownerMenu.UnregisterPopup(this);
			m_FilterInstalled=false;

			// Fire off events
			if(m_PopupContainer!=null)
			{
				if(PopupContainerUnload!=null)
					PopupContainerUnload(this,new EventArgs());
				
				if(ownerMenu!=null)
					ownerMenu.InvokePopupContainerUnload(this,new EventArgs());
			}

			if((m_PopupBar!=null || m_PopupMenu!=null || m_PopupContainer!=null) && ownerMenu!=null)
			{
                OnPopupClose(EventArgs.Empty);
			}

			if(m_PopupMenu!=null)
			{
                if (this.ContainerControl is IKeyTipsControl)
                {
                    IKeyTipsControl kc = this.ContainerControl as IKeyTipsControl;
                    kc.ShowKeyTips = m_PopupMenu.ShowKeyTips;
                    m_PopupMenu.ShowKeyTips = false;
                }
                m_PopupMenu.Close();
				m_PopupMenu.Dispose();
				m_PopupMenu=null;
			}
			if(m_PopupBar!=null)
			{
				m_PopupBar.Hide();
				m_PopupBar.Dispose();
				m_PopupBar=null;
			}
			if(m_PopupContainer!=null)
			{
				m_PopupContainer.Hide();
				m_PopupContainer.Dispose();
				m_PopupContainer=null;
			}
			this.Expanded=false;

			IOwner owner=this.GetOwner() as IOwner;
			if(owner!=null && owner.ParentForm!=null)
			{
				owner.ParentForm.Update();
			}

            OnPopupFinalized(EventArgs.Empty);
		}
예제 #4
0
		/// <summary>
		/// Displays the sub-items on popup menu.
		/// </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>
        /// <param name="verifyScreenPosition">Indicates whether screen position of the menu is verified so the menu always appears on the screen.</param>
		public virtual void PopupMenu(int x, int y, bool verifyScreenPosition)
		{
            PopupPositionAdjusted = false;
			IOwnerMenuSupport ownerMenu=this.GetIOwnerMenuSupport();

			//if(ownerMenu==null)
			//	throw(new InvalidOperationException("Current owner is not assigned or it does not have popup menu support."));

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

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

			if(this.SubItemsImageSize.Width==ImageItem._InitalImageSize.Width && this.SubItemsImageSize.Height==ImageItem._InitalImageSize.Height)
			{
				m_OldSubItemsImageSize=this.SubItemsImageSize;
				this.SubItemsImageSize=new Size(16,16);
			}

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

			if(m_PopupMenu==null)
			{
				m_PopupMenu=new MenuPanel();
				m_PopupMenu.Owner=this.GetOwner();
                m_PopupMenu.UseWholeScreenForSizeChecking = !verifyScreenPosition;

				if(m_PopupFont!=null)
					m_PopupMenu.Font=m_PopupFont;
                else if (objCtrl != null && objCtrl.Font != null)
                {
                    if (objCtrl.GetType().Name.Contains("MetroTabStrip") && objCtrl.Parent != null && objCtrl.Parent.Font != null)
                        m_PopupMenu.Font = objCtrl.Parent.Font;
                    else
                        m_PopupMenu.Font = objCtrl.Font; // (System.Drawing.Font)objCtrl.Font.Clone();
                }
				
				if(ownerMenu!=null && ownerMenu.AlwaysShowFullMenus)
					m_PopupMenu.PersonalizedMenus=ePersonalizedMenus.Disabled;
				else
                    m_PopupMenu.PersonalizedMenus=m_PersonalizedMenus;
				if(ownerMenu!=null && !ownerMenu.ShowFullMenusOnHover && (m_PopupMenu.PersonalizedMenus==ePersonalizedMenus.DisplayOnHover || m_PopupMenu.PersonalizedMenus==ePersonalizedMenus.Both))
					m_PopupMenu.PersonalizedMenus=ePersonalizedMenus.DisplayOnClick;

				m_PopupMenu.PopupAnimation=m_PopupAnimation;

				if(ownerMenu!=null && (this.IsOnMenuBar || this.IsOnMenu))
				{
					m_PopupMenu.PersonalizedAllVisible=ownerMenu.PersonalizedAllVisible;
				}

				if(this.Parent is CustomizeItem || this is CustomizeItem && !(this is QatCustomizeItem))
					m_PopupMenu.IsCustomizeMenu=true;

				if(objCtrl is Bar)
				{
                    Bar bar=(Bar)objCtrl;
                    m_PopupMenu.ColorScheme = bar.GetColorScheme();
                    m_PopupMenu.ShowToolTips = bar.ShowToolTips;
                    m_PopupMenu.AntiAlias = bar.AntiAlias;
                    if (objCtrl is ContextMenuBar)
                        m_PopupMenu.UseWholeScreenForSizeChecking = true;
				}
				else if(objCtrl is MenuPanel)
				{
                    MenuPanel menuPanel = (MenuPanel)objCtrl;
                    m_PopupMenu.ColorScheme = menuPanel.ColorScheme;
                    m_PopupMenu.ShowToolTips = menuPanel.ShowToolTips;
                    m_PopupMenu.AntiAlias = menuPanel.AntiAlias;
				}
				else if(objCtrl is SideBar)
					m_PopupMenu.ColorScheme=((SideBar)objCtrl).ColorScheme;
                else if (objCtrl is ExplorerBar)
                {
                    ExplorerBar eb = objCtrl as ExplorerBar;
                    m_PopupMenu.ColorScheme = eb.ColorScheme;
                    m_PopupMenu.AntiAlias = eb.AntiAlias;
                }
                else if (objCtrl is BarBaseControl)
                    m_PopupMenu.ColorScheme = ((BarBaseControl)objCtrl).ColorScheme;
                else if (objCtrl is ItemControl)
                {
                    ItemControl ic = (ItemControl)objCtrl;
                    m_PopupMenu.ColorScheme = ic.GetColorSchemeInternal();
                    m_PopupMenu.AntiAlias = ic.AntiAlias;
                }
                else if (objCtrl is PopupItemControl)
                {
                    PopupItemControl bx = (PopupItemControl)objCtrl;
                    m_PopupMenu.ColorScheme = bx.GetColorScheme();
                    m_PopupMenu.AntiAlias = bx.AntiAlias;
                }
                else
                {
                    if (this.Style == eDotNetBarStyle.StyleManagerControlled && GlobalManager.Renderer is Office2007Renderer)
                    {
                        m_PopupMenu.ColorScheme = ((Office2007Renderer)GlobalManager.Renderer).ColorTable.LegacyColors;
                    }
                    else
                    {
                        m_PopupMenu.ColorScheme = new ColorScheme(this.EffectiveStyle);
                    }
                    object own = this.GetOwner();
                    if (own is ItemControl)
                    {
                        m_PopupMenu.AntiAlias = ((ItemControl)own).AntiAlias;
                    }
                    else if (own is Bar)
                    {
                        m_PopupMenu.AntiAlias = ((Bar)own).AntiAlias;
                    }
                }

                if (objCtrl != null)
                    m_PopupMenu.RightToLeft = objCtrl.RightToLeft;

				m_PopupMenu.SideBar=m_SideBar;
				m_PopupMenu.ParentItem=this;
				m_PopupMenu.CreateControl();
				m_PopupMenu.RecalcSize();
			}

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

			Rectangle workingArea=objScreen.WorkingArea;
            if (this.Parent == null)
            {
                workingArea = objScreen.Bounds;
                m_PopupMenu.UseWholeScreenForSizeChecking = true;
            }

			if(this.IsRightHanded)
			{
				// When working with right-handed menus for TabletPC the coordinates passed here are
				// the upper right x,y coordinates since menus are right aligned...
				x-=m_PopupMenu.Width;
                if (objScreen != null && x < workingArea.Left && verifyScreenPosition)
				{
                    PopupPositionAdjusted = true;
					// Push it to the right side
					if(this.Displayed && objCtrl!=null && (m_PopupMenu.IsCustomizeMenu || this.IsOnMenu))
					{
						Point p,ps;
						
						if(m_PopupMenu.IsCustomizeMenu)
						{
							p=new Point(m_Rect.Right,m_Rect.Bottom);
						}
						else
						{
							p=new Point(m_Rect.Right,m_Rect.Top);
						}

						ps=objCtrl.PointToScreen(p);
						x=ps.X;
                        if (x + m_PopupMenu.Width > workingArea.Right)
                        {
                            x = workingArea.Right - m_PopupMenu.Width;
                        }
					}
					else
						x=workingArea.Left;
				}
			}
			else
			{
                if (objScreen != null && (x + m_PopupMenu.Width > workingArea.Right || x < workingArea.Left) && verifyScreenPosition)
                {
                    PopupPositionAdjusted = true;
                    if (x + m_PopupMenu.Width > workingArea.Right)
                    {
                        // Push it to the right side
                        if (this.Displayed && objCtrl != null && !(objCtrl is ContextMenuBar))
                        {
                            Point p, ps;

                            if (m_PopupMenu.IsCustomizeMenu)
                            {
                                p = new Point(m_Rect.Left, m_Rect.Bottom);
                            }
                            else
                            {
                                if (this.IsOnMenu)
                                    p = new Point(m_Rect.Left, m_Rect.Top);
                                else
                                    p = new Point(m_Rect.Right, m_Rect.Top);
                            }

                            ps = objCtrl.PointToScreen(p);
                            x = ps.X - m_PopupMenu.Width;
                            if (x + m_PopupMenu.Width > workingArea.Right)
                                x = workingArea.Right - m_PopupMenu.Width;
                        }
                        else
                            x = workingArea.Right - m_PopupMenu.Width;
                    }
                    else if (x < workingArea.Left)
                        x = workingArea.Left;
                }
			}

			// Try to fit whole popup menu "nicely"
            if (objScreen != null && verifyScreenPosition)
			{
                if (y + m_PopupMenu.Height > workingArea.Bottom)
                {
                    // If this container is displayed then try to put it above the menu item
                    if (this.Displayed && objCtrl != null && objCtrl.Visible)
                    {
                        Point p = new Point(m_Rect.Left, m_Rect.Bottom - 1), ps;
                        ps = objCtrl.PointToScreen(p);
                        ps.Y += 2;
                        if (ps.Y - m_PopupMenu.Height >= workingArea.Top)
                            y = Math.Min(workingArea.Bottom, ps.Y) - m_PopupMenu.Height;
                        else if (this is ApplicationButton)
                            y = workingArea.Bottom - m_PopupMenu.Height - 4;
                        else if (this is DevComponents.DotNetBar.Metro.MetroAppButton)
                            y = workingArea.Bottom - m_PopupMenu.Height - 4;
                    }
                    else
                        y = workingArea.Bottom - m_PopupMenu.Height;
                    if (y < workingArea.Top)
                        y = workingArea.Top;
                    PopupPositionAdjusted = true;
                }
			}
            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_PopupMenu.Location=new Point(x,y);

            OnPopupShowing(EventArgs.Empty);

			m_PopupMenu.Show();

            if (this.ContainerControl is IKeyTipsControl)
            {
                IKeyTipsControl kc = this.ContainerControl as IKeyTipsControl;
                m_PopupMenu.ShowKeyTips = kc.ShowKeyTips;
                kc.ShowKeyTips = false;
            }

			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;
				}
			}
		}
예제 #5
0
			public PopupMenuAccessibleObject(MenuPanel owner):base(owner)
			{
				m_Owner = owner;
			}