Ejemplo n.º 1
0
        /// <summary>
        ///     Recurse on setting the canvas
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="canvas"></param>
        private void SetCanvas(IContainsSelectableRibbonItems parent, Control canvas)
        {
            if (parent == null) return;

            foreach (RibbonItem item in parent.GetItems())
            {
                item.SetCanvas(canvas);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tries to extract from IContainsRibbonItems.GetContentBounds()
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private Rectangle GetContentBounds(RibbonItem item)
        {
            IContainsSelectableRibbonItems cont = item as IContainsSelectableRibbonItems;

            if (cont == null)
            {
                return(Rectangle.Empty);
            }
            else
            {
                return(cont.GetContentBounds());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Recurse on setting the canvas
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="canvas"></param>
        private void SetCanvas(IContainsSelectableRibbonItems parent, Control canvas)
        {
            try
            {
                if (parent == null)
                {
                    return;
                }

                foreach (RibbonItem item in parent.GetItems())
                {
                    item.SetCanvas(canvas);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 4
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
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Recurse on setting the canvas
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="canvas"></param>
        private void SetCanvas(IContainsSelectableRibbonItems parent, Control canvas)
        {
            if (parent == null) return;

            foreach (RibbonItem item in parent.GetItems())
            {
                item.SetCanvas(canvas);
            }
        }