Esempio n. 1
0
        public Rectangle GetTabBounds(RibbonTabBase targetTab)
        {
            int x = this.RibbonBounds.Left + this.RibbonTabOffset + RibbonTabBase.TabPadding;
            int y = this.RibbonBounds.Top + RibbonTabBase.TabPadding;

            foreach (var tab in this.realTabs)
            {
                if (tab == targetTab)
                {
                    Rectangle bounds = new Rectangle(x, y, tab.TabWidth, this.TabTotalHeight);
                    return(bounds);
                }
                x += tab.TabWidth + RibbonTabBase.TabPadding;
            }
            return(Rectangle.Empty);
        }
Esempio n. 2
0
        public bool OnMouseUp(MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return(false);
            }
            this.pressing = false;
            if (this.capturedItem != null)
            {
                return(this.capturedItem.OnMouseUp(e));
            }

            bool          result      = false;
            RibbonTabBase selectedTab = GetTabFromPoint(e.Location);

            if (selectedTab != null)
            {
                if (selectedTab.Selectable)
                {
                    result            = ClearTabStates(false);
                    selectedTab.State = RibbonElementState.Selected;
                }
                else
                {
                    selectedTab.State = RibbonElementState.Normal;
                }
                selectedTab.Executed();
                if (selectedTab.Selectable)
                {
                    return(result);
                }
            }
            result = ClearTabStates(true);

            if (this.SelectedTabPanel != null)
            {
                RibbonGroup group = this.SelectedTabPanel.GetGroupFromPoint(e.Location);
                if (group != null)
                {
                    if (group.OnMouseUp(e))
                    {
                        return(true);
                    }
                }
            }
            return(result);
        }
Esempio n. 3
0
        public bool OnMouseMove(MouseEventArgs e)
        {
            if (this.capturedItem != null)
            {
                return(this.capturedItem.OnMouseMove(e));
            }
            bool          result      = ClearTabStates(true);
            RibbonTabBase selectedTab = GetTabFromPoint(e.Location);

            if (selectedTab != null)
            {
                RibbonElementState expectedState = this.pressing ? RibbonElementState.Pressed : RibbonElementState.Hot;
                if (selectedTab.State != RibbonElementState.Selected && selectedTab.State != expectedState)
                {
                    selectedTab.State = expectedState;
                    return(true);
                }
            }

            if (this.SelectedTabPanel != null)
            {
                RibbonGroup group = this.SelectedTabPanel.GetGroupFromPoint(e.Location);
                foreach (var ribbonGroup in this.SelectedTabPanel.RealGroups)
                {
                    if (ribbonGroup != group)
                    {
                        result = ribbonGroup.OnMouseLeave(new EventArgs()) || result;
                    }
                }
                if (group != null)
                {
                    result = group.OnMouseMove(e) || result;
                }
            }
            return(result);
        }
Esempio n. 4
0
        public bool OnMouseDown(MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return(false);
            }
            pressing = true;
            if (this.capturedItem != null)
            {
                return(this.capturedItem.OnMouseDown(e));
            }
            bool          result      = ClearTabStates(true);
            RibbonTabBase selectedTab = GetTabFromPoint(e.Location);

            if (selectedTab != null)
            {
                if (selectedTab.State != RibbonElementState.Selected)
                {
                    selectedTab.State = RibbonElementState.Pressed;
                    return(true);
                }
            }

            if (this.SelectedTabPanel != null)
            {
                RibbonGroup group = this.SelectedTabPanel.GetGroupFromPoint(e.Location);
                if (group != null)
                {
                    if (group.OnMouseDown(e))
                    {
                        return(true);
                    }
                }
            }
            return(result);
        }