예제 #1
0
 /// <summary>
 /// Registers a popup existance
 /// </summary>
 /// <param name="p"></param>
 internal static void Register(RibbonPopup p)
 {
     if (!pops.Contains(p))
     {
         pops.Add(p);
     }
 }
예제 #2
0
 /// <summary>
 /// Unregisters a popup from existance
 /// </summary>
 /// <param name="p"></param>
 internal static void Unregister(RibbonPopup p)
 {
     if (pops.Contains(p))
     {
         pops.Remove(p);
     }
 }
예제 #3
0
        /// <summary>
        /// Raises the MouseDown event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnMouseDown(MouseEventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

            if (MouseDown != null)
            {
                MouseDown(this, e);
            }

            RibbonPopup pop = Canvas as RibbonPopup;

            if (pop != null)
            {
                if (ClosesDropDownAt(e.Location))
                {
                    RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.ItemClicked);
                }

                OnClick(EventArgs.Empty);
            }

            SetPressed(true);
        }
예제 #4
0
        /// <summary>
        /// Closes specified pop-up and all its descendants
        /// </summary>
        /// <param name="startPopup">Pop-up to close (and its descendants)</param>
        /// <param name="reason">Reason for closing</param>
        public static void Dismiss(RibbonPopup startPopup, DismissReason reason)
        {
            int index = pops.IndexOf(startPopup);

            if (index >= 0)
            {
                Dismiss(index, reason);
            }
        }
예제 #5
0
        /// <summary>
        /// Closes all children of specified pop-up
        /// </summary>
        /// <param name="parent">Pop-up of which children will be closed</param>
        /// <param name="reason">Reason for dismissing</param>
        public static void DismissChildren(RibbonPopup parent, DismissReason reason)
        {
            int index = pops.IndexOf(parent);

            if (index >= 0)
            {
                Dismiss(index + 1, reason);
            }
        }
예제 #6
0
        /// <summary>
        /// Shows the drop down items of the button, as if the dropdown part has been clicked
        /// </summary>
        public void ShowDropDown()
        {
            if (Style == RibbonButtonStyle.Normal || DropDownItems.Count == 0)
            {
                if (DropDown != null)
                {
                    RibbonPopupManager.DismissChildren(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                }
                return;
            }

            if (Style == RibbonButtonStyle.DropDown)
            {
                SetPressed(true);
            }
            else
            {
                _dropDownPressed = true;
            }



            CreateDropDown();
            DropDown.MouseEnter    += new EventHandler(DropDown_MouseEnter);
            DropDown.Closed        += new EventHandler(_dropDown_Closed);
            DropDown.ShowSizingGrip = DropDownResizable;

            RibbonPopup canvasdd = Canvas as RibbonPopup;
            Point       location = OnGetDropDownMenuLocation();
            Size        minsize  = OnGetDropDownMenuSize();

            if (!minsize.IsEmpty)
            {
                DropDown.MinimumSize = minsize;
            }

            OnDropDownShowing(EventArgs.Empty);
            SetDropDownVisible(true);
            DropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            DropDown.Show(location);
        }