Ejemplo n.º 1
0
 public virtual void Render(Graphics g, RibbonThemaSettingsBase settings)
 {
     foreach (var item in this.ControlItems)
     {
         item.Render(g, settings, GetItemBounds(item));
     }
 }
Ejemplo n.º 2
0
        public virtual int GetWidth(Graphics g, RibbonThemaSettingsBase settings, RibbonItemSize size)
        {
            switch (size)
            {
            case RibbonItemSize.Big:
            {
                return(this.ControlItems.Select(i => i.GetWidth(g, settings, size)).Sum() + Math.Max(0, this.ControlItems.Count - 1) * RibbonGroup.GroupPadding);
            }

            case RibbonItemSize.Small:
            case RibbonItemSize.Compact:
            {
                int width       = 0;
                int totalGroups = this.ControlItems.Count / 3 + (this.ControlItems.Count % 3 == 0 ? 0 : 1);
                for (int i = 0; i < totalGroups; i++)
                {
                    int start = i * 3;
                    int end   = Math.Min(i * 3 + 2, this.ControlItems.Count - 1);
                    width += Enumerable.Range(start, end - start + 1).Select(j => this.ControlItems[j].GetWidth(g, settings, size)).Max();
                }
                return(width + Math.Max(0, totalGroups - 1) * RibbonGroup.GroupPadding);
            }

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 3
0
 protected void UpdateGroup(RibbonGroup group, Graphics g, RibbonThemaSettingsBase settings)
 {
     group.TabPanel = this;
     group.Services = this.Owner.Container;
     group.Update(g, settings);
     group.WidthLevel = group.WidthLevelCount - 1;
 }
Ejemplo n.º 4
0
        public override void Update(Graphics g, RibbonThemaSettingsBase settings)
        {
            base.Update(g, settings);
            foreach (var item in this.BigItems)
            {
                item.ItemContainer = this;
                item.ItemSize      = RibbonItemSize.Big;
                item.Update(g, settings);
            }
            foreach (var item in this.SmallItems)
            {
                item.ItemContainer = this;
                item.ItemSize      = RibbonItemSize.Small;
                item.Update(g, settings);
            }

            this.bigWidth = this.BigItems.Select(item => item.GetWidth(g, settings, RibbonItemSize.Big)).ToArray();
            int smallGroups = (this.SmallItems.Count + 2) / 3;

            this.smallWidth        = new int[smallGroups];
            this.smallCompactWidth = new int[smallGroups];
            for (int i = 0; i < smallGroups; i++)
            {
                int start = i * 3;
                int end   = Math.Min(i * 3 + 2, this.SmallItems.Count - 1);
                this.smallWidth[i]        = this.SmallItems.Skip(start).Take(end - start + 1).Select(item => item.GetWidth(g, settings, RibbonItemSize.Small)).Max();
                this.smallCompactWidth[i] = this.SmallItems.Skip(start).Take(end - start + 1).Select(item => item.GetWidth(g, settings, RibbonItemSize.Compact)).Max();
            }
        }
Ejemplo n.º 5
0
        public virtual void UpdateWithSizeDecided(Graphics g, RibbonThemaSettingsBase settings)
        {
            int w = GetWidth(g, settings, this.ItemSize);
            int h = GetHeight(g, settings, this.ItemSize);

            this.UpdatedSize = new Size(w, h);
        }
Ejemplo n.º 6
0
        private void RenderDropDown(Graphics g, RibbonThemaSettingsBase settings, Rectangle itemBounds, Rectangle iconBounds)
        {
            switch (this.ItemSize)
            {
            case RibbonItemSize.Big:
            {
                if (this.EnabledDropDown)
                {
                    int       dx = itemBounds.Left + (int)(itemBounds.Width - ButtonDropDownWidth) / 2;
                    int       dy = itemBounds.Bottom - ButtonDropDownHeight - ButtonTextPadding;
                    Rectangle dr = new Rectangle(dx, dy, ButtonDropDownWidth, ButtonDropDownHeight);
                    settings.DrawDownDropDownTriangle(g, settings.ButtonDropDownLight, settings.ButtonDropDownDark, dr);
                }
            }
            break;

            case RibbonItemSize.Small:
            case RibbonItemSize.Compact:
            case RibbonItemSize.ToolStrip:
            {
                if (this.EnabledDropDown)
                {
                    int       dx = itemBounds.Right - ButtonDropDownWidth - ButtonTextPadding;
                    int       dy = itemBounds.Top + (int)(itemBounds.Height - ButtonDropDownHeight) / 2;
                    Rectangle dr = new Rectangle(dx, dy, ButtonDropDownWidth, ButtonDropDownHeight);
                    settings.DrawDownDropDownTriangle(g, settings.ButtonDropDownLight, settings.ButtonDropDownDark, dr);
                }
            }
            break;
            }
        }
Ejemplo n.º 7
0
        private int GetSmallWidth(Graphics g, RibbonThemaSettingsBase settings)
        {
            SizeF size          = g.MeasureString(this.Name, settings.Font);
            int   dropDownWidth = this.EnabledDropDown ? ButtonDropDownSpaceAdditionalWidth : 0;

            return(ButtonSmallIconSize + dropDownWidth + 2 * ButtonBorder + 2 * ButtonTextPadding + (int)size.Width);
        }
Ejemplo n.º 8
0
 public virtual void UpdateWithSizeDecided(Graphics g, RibbonThemaSettingsBase settings)
 {
     foreach (var item in this.ToolItems)
     {
         item.UpdateWithSizeDecided(g, settings);
     }
 }
Ejemplo n.º 9
0
        public override void Update(Graphics g, RibbonThemaSettingsBase settings)
        {
            base.Update(g, settings);
            int w = 0;
            int h = 0;

            foreach (var item in this.MenuItems)
            {
                item.ItemContainer = this;
                item.ItemSize      = RibbonItemSize.MenuItem;
                item.Update(g, settings);
                RibbonMenuItem menuItem = item as RibbonMenuItem;
                if (menuItem != null)
                {
                    w = Math.Max(w, menuItem.UpdatedMenuIconAreaSize.Width);
                    h = Math.Max(w, menuItem.UpdatedMenuIconAreaSize.Height);
                }
            }
            foreach (var item in this.MenuItems)
            {
                RibbonMenuItem menuItem = item as RibbonMenuItem;
                if (menuItem != null)
                {
                    menuItem.UpdatedMenuIconAreaSize = new Size(w, h);
                }
            }
        }
Ejemplo n.º 10
0
 public virtual void Render(Graphics g, RibbonThemaSettingsBase settings)
 {
     foreach (var item in this.ToolItems)
     {
         item.Render(g, settings, GetItemBounds(item));
     }
     settings.DrawCarvedBorder(g, settings.LightBorder, settings.DarkBorder, this.Group.GetToolStripBounds(this));
 }
Ejemplo n.º 11
0
 public override void Render(Graphics g, RibbonThemaSettingsBase settings, Rectangle groupBounds)
 {
     base.Render(g, settings, groupBounds);
     foreach (var tool in this.ToolStrips)
     {
         tool.Render(g, settings);
     }
 }
Ejemplo n.º 12
0
        public override void Update(System.Drawing.Graphics g, RibbonThemaSettingsBase settings)
        {
            SizeF size = g.MeasureString(this.Name, settings.Font);

            this.TabWidth  = (int)size.Width + TabWidthOffset;
            this.TabHeight = (int)size.Height + TabHeightOffset;
            this.State     = RibbonElementState.Normal;
        }
Ejemplo n.º 13
0
 public override int GetHeight(System.Drawing.Graphics g, RibbonThemaSettingsBase settings, RibbonItemSize itemSize)
 {
     if (itemSize != RibbonItemSize.MenuItem)
     {
         throw new NotSupportedException();
     }
     return(3);
 }
Ejemplo n.º 14
0
 public override void Render(Graphics g, RibbonThemaSettingsBase settings, Rectangle itemBounds)
 {
     base.Render(g, settings, itemBounds);
     foreach (var panel in this.Panels)
     {
         panel.Render(g, settings);
     }
 }
Ejemplo n.º 15
0
        public override void Update(Graphics g, RibbonThemaSettingsBase settings)
        {
            base.Update(g, settings);
            SizeF size = g.MeasureString(this.Name, settings.Font);

            this.HeaderMinWidth  = (int)size.Width + 2 * GroupHeaderPadding;
            this.HeaderMinHeight = (int)size.Height + 2 * GroupHeaderPadding;
            this.HeaderHeight    = this.HeaderMinHeight;
        }
Ejemplo n.º 16
0
 public override void Update(System.Drawing.Graphics g, RibbonThemaSettingsBase settings)
 {
     base.Update(g, settings);
     foreach (var tool in this.ToolStrips)
     {
         tool.Group = this;
         tool.Update(g, settings);
     }
 }
Ejemplo n.º 17
0
 public override void Update(Graphics g, RibbonThemaSettingsBase settings)
 {
     base.Update(g, settings);
     foreach (var panel in this.Panels)
     {
         panel.Group = this;
         panel.Update(g, settings);
     }
 }
Ejemplo n.º 18
0
 public virtual void UpdateWithSizeDecided(Graphics g, RibbonThemaSettingsBase settings)
 {
     foreach (var item in this.ControlItems)
     {
         item.ItemSize = this.ItemSize;
         item.UpdateWithSizeDecided(g, settings);
     }
     this.UpdatedWidth = GetWidth(g, settings, this.ItemSize);
 }
Ejemplo n.º 19
0
        public override void Render(Graphics g, RibbonThemaSettingsBase settings, Rectangle itemBounds)
        {
            RenderPanel(g, settings, itemBounds);
            Rectangle iconBounds = GetIconBounds(itemBounds);

            RenderImage(g, settings, itemBounds, iconBounds);
            RenderText(g, settings, itemBounds, iconBounds);
            RenderDropDown(g, settings, itemBounds, iconBounds);
            RenderBorder(g, settings, itemBounds);
        }
Ejemplo n.º 20
0
        public override int GetWidth(System.Drawing.Graphics g, RibbonThemaSettingsBase settings, RibbonItemSize itemSize)
        {
            if (itemSize != RibbonItemSize.MenuItem)
            {
                throw new NotSupportedException();
            }
            SizeF size = g.MeasureString(this.Name, settings.Font);

            return(this.UpdatedMenuIconAreaSize.Width + 2 * MenuButtonLeftPadding + (int)size.Width + (this.DropDown != null ? MenuDropDownArrowArea : 0));
        }
Ejemplo n.º 21
0
        public override void Render(System.Drawing.Graphics g, RibbonThemaSettingsBase settings, Rectangle itemBounds)
        {
            g.FillRectangle(settings.MenuIconBackground.Brush, GetIconBounds(itemBounds));
            g.FillRectangle(settings.Menu.Brush, GetPanelBounds(itemBounds));
            int x  = itemBounds.Left + this.UpdatedMenuIconAreaSize.Width;
            int y1 = itemBounds.Top;
            int y2 = itemBounds.Bottom - 1;

            g.DrawLine(settings.MenuSeparator.Pen, x, y1, x, y2);
        }
Ejemplo n.º 22
0
        public override void Render(System.Drawing.Graphics g, RibbonThemaSettingsBase settings, System.Drawing.Rectangle itemBounds)
        {
            base.Render(g, settings, itemBounds);
            Rectangle r  = GetPanelBounds(itemBounds);
            int       x1 = r.Left + 5;
            int       x2 = r.Right - 5;
            int       y  = r.Top + 1;

            g.DrawLine(settings.MenuSeparator.Pen, x1, y, x2, y);
        }
Ejemplo n.º 23
0
 private void RenderDropDown(Graphics g, RibbonThemaSettingsBase settings, Rectangle itemBounds)
 {
     if (this.DropDown != null)
     {
         int       dx = itemBounds.Right - ButtonDropDownWidth - ButtonDropDownPadding;
         int       dy = itemBounds.Top + (int)(itemBounds.Height - ButtonDropDownHeight) / 2;
         Rectangle dr = new Rectangle(dx, dy, ButtonDropDownWidth, ButtonDropDownHeight);
         settings.DrawDownDropDownTriangle(g, settings.ButtonDropDownLight, settings.ButtonDropDownDark, dr);
     }
 }
Ejemplo n.º 24
0
 public override void Update(Graphics g, RibbonThemaSettingsBase settings)
 {
     if (this.Toggled && this.EnabledToggling)
     {
         UpdateVisualStyle(VisualState.Pressed);
     }
     else
     {
         UpdateVisualStyle(VisualState.Normal);
     }
 }
Ejemplo n.º 25
0
 public override void UpdateWithSizeDecided(Graphics g, RibbonThemaSettingsBase settings)
 {
     base.UpdateWithSizeDecided(g, settings);
     RibbonItemSize[] sizes = GetPanelSizesFromLevel(this.WidthLevel);
     for (int i = 0; i < this.Panels.Count; i++)
     {
         RibbonControlGroupPanel panel = this.Panels[i];
         panel.ItemSize = sizes[i];
         panel.UpdateWithSizeDecided(g, settings);
     }
 }
Ejemplo n.º 26
0
        public override void RenderTab(System.Drawing.Graphics g, RibbonThemaSettingsBase settings, System.Drawing.Rectangle tabBounds)
        {
            RenderPanel(g, settings, tabBounds);
            RenderBorder(g, settings, tabBounds);
            RenderDropDown(g, settings, tabBounds);
            SizeF size = g.MeasureString(this.Name, settings.Font);
            int   tx   = tabBounds.Left + (tabBounds.Width - (int)size.Width) / 2;
            int   ty   = tabBounds.Bottom - TabHeightOffset / 2 - (int)size.Height;

            g.DrawString(this.Name, settings.Font, settings.TabText.Brush, tx, ty);
        }
Ejemplo n.º 27
0
 public override void Update(Graphics g, RibbonThemaSettingsBase settings)
 {
     base.Update(g, settings);
     if (this.SmallImage != null)
     {
         int  w = this.SmallImage.Width + 2 * MenuIconPadding;
         int  h = this.SmallImage.Height + 2 * MenuIconPadding;
         Size s = this.UpdatedMenuIconAreaSize;
         this.UpdatedMenuIconAreaSize = new Size(Math.Max(s.Width, w), Math.Max(s.Height, h));
     }
 }
Ejemplo n.º 28
0
 public override void UpdateWithSizeDecided(Graphics g, RibbonThemaSettingsBase settings)
 {
     base.UpdateWithSizeDecided(g, settings);
     for (int i = 0; i < this.SmallItems.Count; i++)
     {
         RibbonItem item  = this.SmallItems[i];
         int        group = i / 3;
         item.ItemSize = group < this.WidthLevel ? RibbonItemSize.Small : RibbonItemSize.Compact;
         item.UpdateWithSizeDecided(g, settings);
     }
 }
Ejemplo n.º 29
0
        public override void UpdateWithSizeDecided(Graphics g, RibbonThemaSettingsBase settings)
        {
            base.UpdateWithSizeDecided(g, settings);
            foreach (var item in this.MenuItems)
            {
                item.UpdateWithSizeDecided(g, settings);
            }
            int w = MenuBorder * 2 + (this.MenuItems.Count == 0 ? 0 : this.MenuItems.Select(i => i.GetWidth(g, settings, i.ItemSize)).Max());
            int h = MenuBorder * 2 + this.MenuItems.Select(i => i.GetHeight(g, settings, i.ItemSize)).Sum();

            this.TotalSize = new Size(w, h);
        }
Ejemplo n.º 30
0
 public virtual void Update(Graphics g, RibbonThemaSettingsBase settings)
 {
     foreach (var item in this.ToolItems)
     {
         item.ItemContainer = this.Group;
         item.ToolStrip     = this;
         item.ItemSize      = RibbonItemSize.ToolStrip;
         item.Update(g, settings);
     }
     this.UpdatedWidth  = this.ToolItems.Select(i => i.GetWidth(g, settings, i.ItemSize)).Sum() + 2 * ToolStripBorder;
     this.toolItemWidth = this.ToolItems.Select(i => i.GetWidth(g, settings, i.ItemSize)).ToArray();
 }