Exemplo n.º 1
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);
        }
 /// <summary>
 /// Registers a popup existance
 /// </summary>
 /// <param name="p"></param>
 internal static void Register(RibbonPopup p)
 {
     if (!pops.Contains(p))
     {
         pops.Add(p);
     }
 }
 /// <summary>
 /// Unregisters a popup from existance
 /// </summary>
 /// <param name="p"></param>
 internal static void Unregister(RibbonPopup p)
 {
     if (pops.Contains(p))
     {
         pops.Remove(p);
     }
 }
        /// <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);
            }
        }
Exemplo n.º 5
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);

                PopupUnRegistered(p, EventArgs.Empty);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Registers a popup existance
        /// </summary>
        /// <param name="p"></param>
        internal static void Register(RibbonPopup p)
        {
            if (!pops.Contains(p))
            {
                pops.Add(p);

                PopupRegistered(p, EventArgs.Empty);
            }
        }
        /// <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);
            }
        }
Exemplo n.º 8
0
        public override void OnClick(EventArgs e)
        {
            //we need to override the onclick otherwise clicking on the scrollbar will close the popup window
            RibbonPopup pop = Canvas as RibbonPopup;

            if (pop == null)
            {
                base.OnClick(e);
            }
        }
Exemplo n.º 9
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)
            {
                if (DropDown != null)
                {
                    RibbonPopupManager.DismissChildren(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                }
                return;
            }

            if (Style == RibbonButtonStyle.DropDown)
            {
                SetPressed(true);
            }
            else
            {
                _dropDownPressed = true;
            }
            OnDropDownShowing(EventArgs.Empty);
            if (DropDownItems.Count == 0)
            {
                if (DropDown != null)
                {
                    RibbonPopupManager.DismissChildren(DropDown, RibbonPopupManager.DismissReason.NewPopup);
                }
                return;
            }
            AssignHandlers();

            CreateDropDown();
            DropDown.MouseEnter    += new EventHandler(DropDown_MouseEnter);
            DropDown.Closed        += new EventHandler(DropDown_Closed);
            DropDown.ShowSizingGrip = DropDownResizable;
            DropDown.DrawIconsBar   = DrawDropDownIconsBar;

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

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

            SetDropDownVisible(true);
            DropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            DropDown.Show(location);
        }
Exemplo n.º 10
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)
            {
                CloseDropDown();
                return;
            }

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

            OnDropDownShowing(EventArgs.Empty);

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

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

            if (canvasdd != null)
            {
                canvasdd.NextPopup     = DropDown;
                DropDown.PreviousPopup = canvasdd;
            }

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

            SetDropDownVisible(true);
            DropDown.SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            DropDown.Show(location);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Raises the Click event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnClick(EventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

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

            RibbonPopup pop = Canvas as RibbonPopup;

            if (pop != null)
            {
                if (ClosesDropDownAt(Cursor.Position))
                {
                    RibbonPopupManager.Dismiss(RibbonPopupManager.DismissReason.ItemClicked);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Raises the MouseDown event
        /// </summary>
        /// <param name="e">Event data</param>
        public virtual void OnMouseDown(MouseEventArgs e)
        {
            if (!Enabled)
            {
                return;
            }

            RibbonPopup pop = Canvas as RibbonPopup;

            if (pop != null)
            {
                if (ClosesDropDownAt(e.Location))
                {
                    pop.CloseAll();
                }
            }

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

            SetPressed(true);
        }
        /// <summary>
        /// Unregisters a popup from existance
        /// </summary>
        /// <param name="p"></param>
        internal static void Unregister(RibbonPopup p)
        {
            if (pops.Contains(p))
            {
                pops.Remove(p);

                PopupUnRegistered(p, EventArgs.Empty);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Registers a popup existance
 /// </summary>
 /// <param name="p"></param>
 internal static void Register(RibbonPopup p)
 {
     if (!pops.Contains(p))
     {
         pops.Add(p);
     }
 }
Exemplo n.º 15
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);
     }
 }
        /// <summary>
        /// Registers a popup existance
        /// </summary>
        /// <param name="p"></param>
        internal static void Register(RibbonPopup p)
        {
            if (!pops.Contains(p))
            {
                pops.Add(p);

                PopupRegistered(p, EventArgs.Empty);
            }
        }
        /// <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);
            }
        }
        /// <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);
            }
        }