Esempio n. 1
0
        internal RibbonPanelPopup(RibbonPanel panel)
        {
            DoubleBuffered = true;

            _sensor            = new RibbonSensor(this, panel.Owner, panel.OwnerTab);
            _sensor.PanelLimit = panel;
            _panel             = panel;
            _panel.PopUp       = this;

            using (Graphics g = CreateGraphics())
            {
                Size s = panel.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g,
                                                                                       GetSizeMode(panel)));
                //s.Width+=3; s.Height+=3;
                Size = s;
                panel.SetBounds(new Rectangle(0, 0, Size.Width, Size.Height));
                panel.UpdateItemsRegions(g, GetSizeMode(panel));
            }

            foreach (RibbonItem item in panel.Items)
            {
                item.SetCanvas(this);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the regions of the panels and its contents
        /// </summary>
        internal void UpdatePanelsRegions()
        {
            if (Panels.Count == 0)
            {
                return;
            }

            bool dMode = Site != null && Site.DesignMode;

            if (!dMode)
            {
                _offset = 0;
            }

            int curRight  = TabContentBounds.Left + Owner.PanelPadding.Left + _offset;
            int panelsTop = TabContentBounds.Top + Owner.PanelPadding.Top;

            using (Graphics g = Owner.CreateGraphics())
            {
                //Check all at full size
                foreach (RibbonPanel panel in Panels)
                {
                    RibbonElementSizeMode sMode = panel.FlowsTo == RibbonPanelFlowDirection.Right ? RibbonElementSizeMode.Medium : RibbonElementSizeMode.Large;
                    //Set the bounds of the panel to let it know it's height
                    panel.SetBounds(new Rectangle(0, 0, 1, TabContentBounds.Height - Owner.PanelPadding.Vertical));

                    ///Size of the panel
                    Size size = panel.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g, sMode));

                    ///Creates the bounds of the panel
                    Rectangle bounds = new Rectangle(
                        curRight, panelsTop,
                        size.Width, size.Height);

                    ///Set the bouns of the panel
                    panel.SetBounds(bounds);

                    ///Let the panel know what size we have decided for it
                    panel.SetSizeMode(sMode);

                    ///Update curLeft
                    curRight = bounds.Right + 1 + Owner.PanelSpacing;
                }


                if (!dMode)
                {
                    while (curRight > TabContentBounds.Right && !AllPanelsOverflow())
                    {
                        #region Down grade the larger panel one position

                        RibbonPanel larger = GetLargerPanel();

                        if (larger.SizeMode == RibbonElementSizeMode.Large)
                        {
                            larger.SetSizeMode(RibbonElementSizeMode.Medium);
                        }
                        else if (larger.SizeMode == RibbonElementSizeMode.Medium)
                        {
                            larger.SetSizeMode(RibbonElementSizeMode.Compact);
                        }
                        else if (larger.SizeMode == RibbonElementSizeMode.Compact)
                        {
                            larger.SetSizeMode(RibbonElementSizeMode.Overflow);
                        }

                        Size size = larger.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g, larger.SizeMode));

                        larger.SetBounds(new Rectangle(larger.Bounds.Location, new Size(size.Width + Owner.PanelMargin.Horizontal, size.Height)));

                        #endregion

                        ///Reset x-axis reminder
                        curRight = TabContentBounds.Left + Owner.PanelPadding.Left;

                        ///Re-arrange location because of the new bounds
                        foreach (RibbonPanel panel in Panels)
                        {
                            Size s = panel.Bounds.Size;
                            panel.SetBounds(new Rectangle(new Point(curRight, panelsTop), s));
                            curRight += panel.Bounds.Width + 1 + Owner.PanelSpacing;
                        }
                    }
                }

                ///Update regions of all panels
                foreach (RibbonPanel panel in Panels)
                {
                    panel.UpdateItemsRegions(g, panel.SizeMode);
                }
            }

            UpdateScrollBounds();
        }