Exemple #1
0
        /// <summary>
        /// Feeds mouse Wheel. If applied on a IScrollableItem it's sended to it
        /// </summary>
        /// <param name="e"></param>
        /// <returns>True if handled. False otherwise</returns>
        internal static bool FeedMouseWheel(MouseEventArgs e)
        {
            RibbonDropDown dd = LastPopup as RibbonDropDown;

            if (dd != null)
            {
                foreach (RibbonItem item in dd.Items)
                {
                    if (dd.RectangleToScreen(item.Bounds).Contains(e.Location))
                    {
                        IScrollableRibbonItem sc = item as IScrollableRibbonItem;

                        if (sc != null)
                        {
                            if (e.Delta < 0)
                            {
                                sc.ScrollDown();
                            }
                            else
                            {
                                sc.ScrollUp();
                            }

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Feeds mouse Wheel. If applied on a IScrollableItem it's sended to it
        /// </summary>
        /// <param name="e"></param>
        /// <returns>True if handled. False otherwise</returns>
        internal static bool FeedMouseWheel(MouseEventArgs e)
        {
            RibbonDropDown dd = LastPopup as RibbonDropDown;

            if (dd != null)
            {
                WinApi.POINT pos;
                if (WinApi.GetCursorPos(out pos))
                {
                    foreach (RibbonItem item in dd.Items)
                    {
                        if (dd.RectangleToScreen(item.Bounds).Contains(pos.x, pos.y))
                        //if (dd.RectangleToScreen(item.Bounds).Contains(e.Location))
                        {
                            IScrollableRibbonItem sc = item as IScrollableRibbonItem;

                            if (sc != null)
                            {
                                if (e.Delta < 0)
                                {
                                    sc.ScrollDown();
                                }
                                else
                                {
                                    sc.ScrollUp();
                                }

                                return(true);
                            }
                        }
                    }
                }
            }
            //kevin carbis - added scrollbar support to dropdowns so we need to feed the mouse wheel to the
            //actual dropdown item if it was not intended for a child item.
            if (dd != null)
            {
                if (e.Delta < 0)
                {
                    dd.ScrollDown();
                }
                else
                {
                    dd.ScrollUp();
                }

                return(true);
            }
            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Performs a hit-test and specifies hitted objects on properties: <see cref="HittedPanel"/>,
        /// <see cref="HittedTab"/>, <see cref="HittedItem"/> and <see cref="HittedSubItem"/>
        /// </summary>
        /// <param name="p"></param>
        internal void HitTest(Point p)
        {
            SelectedTab     = HittedTab;
            SelectedPanel   = HittedPanel;
            SelectedItem    = HittedItem;
            SelectedSubItem = HittedSubItem;

            HittedTab            = null;
            HittedTabScrollLeft  = false;
            HittedTabScrollRight = false;
            HittedPanel          = null;
            HittedItem           = null;
            HittedSubItem        = null;

            #region Tabs
            if (TabLimit != null && TabLimit.Visible)
            {
                if (TabLimit.TabContentBounds.Contains(p))
                {
                    HittedTab = TabLimit;
                }
            }
            else
            {
                foreach (RibbonTab tab in Tabs)
                {
                    if (tab.Visible && tab.TabContentBounds.Contains(p))
                    {
                        HittedTab = tab; break;
                    }
                }
            }
            #endregion

            #region TabScrolls

            if (HittedTab != null)
            {
                HittedTabScrollLeft  = HittedTab.ScrollLeftVisible && HittedTab.ScrollLeftBounds.Contains(p);
                HittedTabScrollRight = HittedTab.ScrollRightVisible && HittedTab.ScrollRightBounds.Contains(p);
            }

            #endregion

            if (!HittedTabScroll)
            {
                #region Panels

                if (PanelLimit != null && PanelLimit.Visible)
                {
                    if (PanelLimit.Bounds.Contains(p))
                    {
                        HittedPanel = PanelLimit;
                    }
                }
                else
                {
                    foreach (RibbonPanel pnl in Panels)
                    {
                        if (pnl.Visible && pnl.Bounds.Contains(p))
                        {
                            HittedPanel = pnl; break;
                        }
                    }
                }

                #endregion

                #region Item

                IEnumerable <RibbonItem> items = Items;

                if (ItemsSource != null)
                {
                    items = ItemsSource;
                }

                foreach (RibbonItem item in items)
                {
                    if (item.OwnerPanel != null && item.OwnerPanel.OverflowMode && !(Control is RibbonPanelPopup))
                    {
                        continue;
                    }

                    if (!item.Visible)
                    {
                        continue;
                    }

                    if (item.Bounds.Contains(p))
                    {
                        HittedItem = item; break;
                    }
                }

                #endregion

                #region Subitem

                IContainsSelectableRibbonItems container  = HittedItem as IContainsSelectableRibbonItems;
                IScrollableRibbonItem          scrollable = HittedItem as IScrollableRibbonItem;


                if (container != null)
                {
                    Rectangle sensibleBounds = scrollable != null ? scrollable.ContentBounds : HittedItem.Bounds;

                    foreach (RibbonItem item in container.GetItems())
                    {
                        if (!item.Visible)
                        {
                            continue;
                        }

                        Rectangle actualBounds = item.Bounds;
                        actualBounds.Intersect(sensibleBounds);

                        if (actualBounds.Contains(p))
                        {
                            HittedSubItem = item;
                        }
                    }
                }

                #endregion
            }
        }