コード例 #1
0
        public void DelayClose(PopupItem item)
        {
            if (m_Timer == null)
                return;

            bool readerLockHeld = m_PopupsLock.IsReaderLockHeld;
            System.Threading.LockCookie cookie1 = new System.Threading.LockCookie();
            if (readerLockHeld)
            {
                cookie1 = m_PopupsLock.UpgradeToWriterLock(-1);
            }
            else
            {
                m_PopupsLock.AcquireWriterLock(-1);
            }

            try
            {
                m_Popups.Add(item);
                m_Timer.Start();
            }
            finally
            {
                if (readerLockHeld)
                {
                    m_PopupsLock.DowngradeFromWriterLock(ref cookie1);
                }
                else
                {
                    m_PopupsLock.ReleaseWriterLock();
                }
            }
        }
コード例 #2
0
 void IOwnerMenuSupport.InvokePopupOpen(PopupItem item, PopupOpenEventArgs e)
 {
     if (PopupOpen != null)
         PopupOpen(item, e);
 }
コード例 #3
0
 void IOwnerMenuSupport.InvokePopupContainerUnload(PopupItem item, EventArgs e)
 {
     if (PopupContainerUnload != null)
         PopupContainerUnload(item, e);
 }
コード例 #4
0
 // Events
 void IOwnerMenuSupport.InvokePopupClose(PopupItem item, EventArgs e)
 {
     if (PopupClose != null)
         PopupClose(item, e);
 }
コード例 #5
0
 void IOwnerMenuSupport.UnregisterPopup(PopupItem objPopup)
 {
     if (m_RegisteredPopups.Contains(objPopup))
         m_RegisteredPopups.Remove(objPopup);
     if (m_RegisteredPopups.Count == 0)
     {
         MenuEventSupportUnhook();
         if (m_Hook != null)
         {
             m_Hook.Dispose();
             m_Hook = null;
         }
         this.MenuFocus = false;
     }
 }
コード例 #6
0
        void IOwnerMenuSupport.RegisterPopup(PopupItem objPopup)
        {
            this.MenuFocus = true;

            if (m_RegisteredPopups.Contains(objPopup))
                return;

            if (!this.GetDesignMode() && !m_UseHook)
            {
                if (!m_FilterInstalled)
                {
                    MessageHandler.RegisterMessageClient(this);
                    m_FilterInstalled = true;
                }
            }
            else
            {
                if (m_Hook == null)
                {
                    m_Hook = new Hook(this);
                }
            }

            if (!m_MenuEventSupport)
                MenuEventSupportHook();

            m_RegisteredPopups.Add(objPopup);
            if (objPopup.GetOwner() != this)
                objPopup.SetOwner(this);
        }
コード例 #7
0
		void IOwnerMenuSupport.RegisterPopup(PopupItem objPopup)
		{
			if(m_RegisteredPopups.Contains(objPopup))
				return;

            if (!this.GetDesignMode() && !m_UseHook)
            {
                InstallMessageFilter();

                if (!m_MenuEventSupport)
                    MenuEventSupportHook();
            }
            else
            {
                if (m_Hook == null)
                {
                    m_Hook = new Hook(this);
                }
            }

			m_RegisteredPopups.Add(objPopup);
			if(objPopup.GetOwner()!=this)
				objPopup.SetOwner(this);
		}
コード例 #8
0
		/// <summary>
		/// Un-registers specified popup. See RegisterPopup for more information.
		/// </summary>
		/// <param name="objPopup"></param>
		public void UnregisterPopup(PopupItem objPopup)
		{
			if(m_RegisteredPopups.Contains(objPopup))
				m_RegisteredPopups.Remove(objPopup);
			if(m_RegisteredPopups.Count==0 && m_Hook!=null && (!m_UseHook || this.DesignMode))
			{
				m_Hook.Dispose();
				m_Hook=null;
			}
		}
コード例 #9
0
 private void CaptionMenuItemClick(object sender, EventArgs e)
 {
     ButtonItem menuItem = sender as ButtonItem;
     if (menuItem == null)
         return;
     if (this.LayoutType == eLayoutType.DockContainer)
         this.SelectedDockTab = this.Items.IndexOf(menuItem.Tag as BaseItem);
     else
     {
         foreach (BaseItem item in this.Items)
         {
             if (item == menuItem.Tag)
                 item.Visible = true;
             else
                 item.Visible = false;
         }
         this.RecalcLayout();
         m_CaptionMenu.Dispose();
         m_CaptionMenu = null;
     }
 }
コード例 #10
0
		void IOwnerMenuSupport.InvokePopupClose(PopupItem item,EventArgs e)
		{
			if(PopupClose!=null)
				PopupClose(item,e);
			#if TRIAL
			if(iCount>iMaxCount || iMaxCount<=0)
			{
				iCount=0;
				RemindForm f=new RemindForm();
				f.ShowDialog();
			}
			#endif
		}
コード例 #11
0
        /// <summary>
        /// Displays or hides the automatic caption button popup menu.
        /// </summary>
        private void ToggleCaptionMenu()
        {
            if (m_CaptionMenu != null)
            {
                bool bClose = m_CaptionMenu.Expanded;
                if (bClose)
                    m_CaptionMenu.ClosePopup();
                m_CaptionMenu.Dispose();
                m_CaptionMenu = null;
                if (bClose)
                    return;
            }

            if (this.Items.Count <= 0)
                return;

            m_CaptionMenu = new ButtonItem("sysCaptionButtonMenuParent");
            m_CaptionMenu.Style = this.Style;
            m_CaptionMenu.PopupShowing += new EventHandler(this.CaptionMenuShowing);
            m_CaptionMenu.PopupFinalized += new EventHandler(this.CaptionMenuClose);
            foreach (BaseItem item in this.Items)
            {
                ButtonItem menuItem = new ButtonItem("sysCaption_" + item.Name);
                menuItem.Tag = item;
                menuItem.OptionGroup = "sysCaptionMenu";
                menuItem.Text = item.Text;
                menuItem.BeginGroup = item.BeginGroup;
                if (item is DockContainerItem)
                {
                    DockContainerItem dock = item as DockContainerItem;
                    menuItem.Checked = item.Displayed;
                    if (dock.Image != null)
                        menuItem.Image = dock.Image.Clone() as System.Drawing.Image;
                    else if (dock.Icon != null)
                        menuItem.Icon = dock.Icon.Clone() as System.Drawing.Icon;
                    else if (dock.ImageIndex >= 0 && dock.ImageList != null)
                        menuItem.Image = dock.ImageList.Images[dock.ImageIndex].Clone() as System.Drawing.Image;
                }
                else
                    menuItem.Checked = item.Visible;
                menuItem.Click += new EventHandler(this.CaptionMenuItemClick);
                m_CaptionMenu.SubItems.Add(menuItem);
            }

            if (m_CaptionMenu.GetOwner() == null)
                m_CaptionMenu.SetOwner(m_Owner);
            System.Drawing.Size size = m_CaptionMenu.PopupSize;
            Point popupLocation = new Point(m_SystemButtons.CaptionButtonRect.Right - size.Width, m_SystemButtons.CaptionButtonRect.Bottom);
            if (popupLocation.X < 0)
                popupLocation.X = 0;
            popupLocation = this.PointToScreen(popupLocation);
            m_CaptionMenu.Popup(popupLocation);
        }
コード例 #12
0
		void IOwnerMenuSupport.InvokePopupOpen(PopupItem item,PopupOpenEventArgs e)
		{
			if(PopupOpen!=null)
				PopupOpen(item,e);
			#if TRIAL
			iCount++;
			#endif
		}
コード例 #13
0
		private void CustomizeItemClick(object sender, System.EventArgs e)
		{
			BaseItem objItem=sender as BaseItem;
			m_ContextMenu.Expanded=false;
			if(objItem.Name=="customize")
			{
				this.Customize();
			}
			else
			{
				Bar bar=objItem.Tag as Bar;
				if(bar.AutoHide)
					bar.AutoHide=false;
                if (!bar.Visible && bar.LayoutType == eLayoutType.DockContainer && bar.VisibleItemCount == 0 && bar.Items.Count > 0)
                    bar.Items[0].Visible = true;
				bar.Visible=!bar.Visible;
				//if(!bar.Visible)
				bar.RecalcLayout();
				bar.InvokeUserVisibleChanged();
			}
			m_ContextMenu.Dispose();
			m_ContextMenu=null;
		}
コード例 #14
0
		void IOwnerBarSupport.BarContextMenu(Control bar, MouseEventArgs e)
		{
			if(!ShowCustomizeContextMenu || m_frmCustomize!=null || this.DesignMode)
				return;

			// Create popup menu that lets users hide/show bars...
			m_ContextMenu=new ButtonItem("sys_customizecontextnmenu");
			ButtonItem btn;
			eDotNetBarStyle style=eDotNetBarStyle.OfficeXP;
			if(m_Bars.Count>0)
				style=m_Bars[0].Style;
			m_ContextMenu.Style=style;
			foreach(Bar b in m_Bars)
			{
                if (b.LayoutType == eLayoutType.DockContainer && b.Items.Count == 0) continue;
				// TODO: Menu Merge implementation
				//if(b.CanHide && (!m_ParentForm.IsMdiChild || !b.MergeEnabled ))
				if(b.CanHide && (b.LayoutType==eLayoutType.DockContainer && b.CanCustomize || b.LayoutType!=eLayoutType.DockContainer) && b.Text!="")
				{
					btn=new ButtonItem();
					btn.Text=b.Text;
					btn.Checked=b.Visible || b.AutoHide;
					btn.SetSystemItem(true);
					btn.Tag=b;
					btn.Click+=new System.EventHandler(this.CustomizeItemClick);
					m_ContextMenu.SubItems.Add(btn);
				}
			}
			btn=new ButtonItem("customize");
			if(m_ContextMenu.SubItems.Count>0)
				btn.BeginGroup=true;
			using(LocalizationManager lm=new LocalizationManager(this))
			{
				btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeItemCustomize);
			}
			btn.SetSystemItem(true);
			btn.Style=style;
			btn.Click+=new System.EventHandler(this.CustomizeItemClick);
			m_ContextMenu.SubItems.Add(btn);
            OnCustomizeContextMenu(this, (ButtonItem)m_ContextMenu);
			this.RegisterPopup(m_ContextMenu);
			m_ContextMenu.PopupMenu(bar.PointToScreen(new Point(e.X,e.Y)));
		}
コード例 #15
0
 void IOwnerMenuSupport.InvokePopupShowing(PopupItem item, EventArgs e)
 {
     if (PopupShowing != null)
         PopupShowing(item, e);
 }
コード例 #16
0
		void IOwnerMenuSupport.RegisterPopup(PopupItem objPopup)
		{
			if(m_RegisteredPopups.Contains(objPopup))
				return;
			
			if(!this.GetDesignMode())
			{
				if(!m_FilterInstalled)
				{
					//System.Windows.Forms.Application.AddMessageFilter(this);
					MessageHandler.RegisterMessageClient(this);
					m_FilterInstalled=true;
				}	
			}
            else
            {
                if (m_Hook == null)
                {
                    m_Hook = new Hook(this);
                }
            }

			if(!m_MenuEventSupport)
				MenuEventSupportHook();

			m_RegisteredPopups.Add(objPopup);
			if(objPopup.GetOwner()!=this)
				objPopup.SetOwner(this);
		}
コード例 #17
0
        public PopupItemControl()
        {
            PainterFactory.InitFactory();
            if (!ColorFunctions.ColorsLoaded)
            {
                NativeFunctions.RefreshSettings();
                NativeFunctions.OnDisplayChange();
                ColorFunctions.LoadColors();
            }
            
            m_PopupItem = CreatePopupItem();
            m_PopupItem.GlobalItem = false;
            m_PopupItem.ContainerControl = this;
            m_PopupItem.Style = eDotNetBarStyle.Office2007;
            m_PopupItem.SetOwner(this);
            m_ColorScheme = new ColorScheme(m_PopupItem.EffectiveStyle);

            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.Opaque, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(DisplayHelp.DoubleBufferFlag, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.SetStyle(ControlStyles.ContainerControl, false);

            this.SetStyle(ControlStyles.Selectable, true);
        }
コード例 #18
0
		/// <summary>
		/// Registers popup item with DotNetBar. Use this function carefully. The registration is required only if Popup item is created completely from code and it is not added to any DotNetBarManager collection.
		/// </summary>
		/// <param name="objPopup"></param>
		public void RegisterPopup(PopupItem objPopup)
		{
			if(m_RegisteredPopups.Contains(objPopup))
				return;
			
			if(!this.DesignMode)
			{
				if(!m_FilterInstalled && !m_UseHook)
				{
					//System.Windows.Forms.Application.AddMessageFilter(this);
					MessageHandler.RegisterMessageClient(this);
					m_FilterInstalled=true;
				}
				else if(m_UseHook && m_Hook==null)
				{
					m_Hook=new Hook(this);
				}
			}
            else if (m_Hook == null)
            {
                m_Hook = new Hook(this);
            }

			m_RegisteredPopups.Add(objPopup);
			if(objPopup.GetOwner()==null)
				objPopup.SetOwner(this);
		}