Пример #1
0
        private void SetupOverflowButton()
        {
            if (m_OverflowButton != null || m_ItemContainer.SubItems.Count==0)
                return;
            m_SuspendRecalcSize = true;

            
            RibbonOverflowButtonItem overflowButton = new RibbonOverflowButtonItem();
            overflowButton.Name = "sysOverflowButton";
            overflowButton.Text = GetOverflowButtonText();
            overflowButton.RibbonBar = this;
            overflowButton.Image = GetOverflowButtonImage();
            overflowButton.ButtonStyle = eButtonStyle.ImageAndText;
            overflowButton.ImagePosition = eImagePosition.Top;
            overflowButton.AutoExpandOnClick = true;
            overflowButton.PopupType = ePopupType.Menu;
            overflowButton.ImagePaddingHorizontal = 16;
            overflowButton.VerticalPadding = 12;
            overflowButton.SubItemsExpandWidth = 14;
            overflowButton.HotTrackingStyle = eHotTrackingStyle.None;
            overflowButton.PopupOpen += new DotNetBarManager.PopupOpenEventHandler(OverflowButton_PopupOpen);
            if (OverflowButtonSetup != null)
                OverflowButtonSetup(this, new OverflowButtonEventArgs(overflowButton));

            ArrayList items = new ArrayList();
            m_ItemContainer.SubItems.CopyTo(items);
            m_ItemContainer.SubItems.Clear();

            //ItemContainer cont = m_ItemContainer.Copy() as ItemContainer;
            //m_OverflowButton.SubItems.Add(cont);
            m_ItemContainer.SubItems.Add(overflowButton);
            m_OverflowRibbonBar = CreateOverflowRibbon();
            m_OverflowRibbonBar.OverflowParent = this;

            m_OriginalVerticalItemAlign = m_ItemContainer.VerticalItemAlignment;
            m_OriginalLayoutOrientation = m_ItemContainer.LayoutOrientation;
            m_OriginalHorizontalItemAlign = m_ItemContainer.HorizontalItemAlignment;
            m_ItemContainer.VerticalItemAlignment = eVerticalItemsAlignment.Top;
            m_ItemContainer.LayoutOrientation = eOrientation.Horizontal;
            m_ItemContainer.HorizontalItemAlignment = eHorizontalItemsAlignment.Center;

            IOwner owner = (IOwner)this;
            foreach (BaseItem item in items)
            {
                m_OverflowRibbonBar.Items.Add(item);
                owner.AddShortcutsFromItem(item);
            }
            
            ItemContainer ic = new ItemContainer();
            ic.Stretch = true;
            ControlContainerItem cont = new ControlContainerItem();
            cont.AllowItemResize = false;
            ic.SubItems.Add(cont);
            cont.Control = m_OverflowRibbonBar;
            overflowButton.SubItems.Add(ic);
			m_ItemContainer.RefreshImageSize();

            m_OverflowButton = overflowButton;

            if (OverflowButtonSetupComplete != null)
                OverflowButtonSetupComplete(this, new OverflowButtonEventArgs(m_OverflowButton));
            m_SuspendRecalcSize = false;
        }
Пример #2
0
        private void DisposeOverflowButton()
        {
            if (m_OverflowButton == null)
                return;

            m_SuspendRecalcSize = true;
            if (OverflowButtonDestroy != null)
                OverflowButtonDestroy(this, new OverflowButtonEventArgs(m_OverflowButton));
            m_OverflowButton.PopupOpen -= new DotNetBarManager.PopupOpenEventHandler(OverflowButton_PopupOpen);
            m_ItemContainer.SubItems.Remove(m_OverflowButton);
            m_ItemContainer.VerticalItemAlignment = m_OriginalVerticalItemAlign;
            m_ItemContainer.LayoutOrientation = m_OriginalLayoutOrientation;
            m_ItemContainer.HorizontalItemAlignment = m_OriginalHorizontalItemAlign;
            ArrayList items=new ArrayList();
            m_OverflowRibbonBar.Items.CopyTo(items);
            m_OverflowRibbonBar.Items.Clear();
            m_OverflowButton.SubItems.Clear();

            IOwner owner = (IOwner)this;
            foreach (BaseItem item in items)
            {
                owner.RemoveShortcutsFromItem(item);
                m_ItemContainer.SubItems.Add(item);
            }
			if(m_OverflowButtonImage==null)
			{
				m_OverflowButton.Image.Dispose();
				m_OverflowButton.Image=null;
			}
            m_OverflowButton.Dispose();
            m_OverflowRibbonBar.Dispose();
            m_OverflowButton = null;
            m_OverflowRibbonBar = null;
            m_SuspendRecalcSize = false;
            m_BeforeOverflowSize = Size.Empty;
        }
Пример #3
0
 public static ButtonItemPainter CreateRibbonOverflowButtonPainter(RibbonOverflowButtonItem button)
 {
     if (BarFunctions.IsOffice2007Style(button.EffectiveStyle))
         return m_Office2007RibbonOverflowPainter;
     return null;
 }