예제 #1
0
 /// <summary>
 /// Renders the MetroTabStrip
 /// </summary>
 /// <param name="tabStrip">TabStrip to render.</param>
 /// <param name="pa">Paint args</param>
 public static void Paint(MetroTabStrip tabStrip, ItemPaintArgs pa)
 {
     MetroRenderer renderer = GetRenderer(Renderers.MetroTabStrip);
     renderer.Render(GetRenderingInfo(tabStrip, pa, GetColorTable()));
 }
예제 #2
0
        private void SetQatAndCaptionItemBounds(MetroTabStrip strip,MetroRendererInfo renderingInfo)
        {
            if (!strip.CaptionVisible)
                return;
            bool rightToLeft = (strip.RightToLeft == System.Windows.Forms.RightToLeft.Yes);
            
            System.Windows.Forms.Form form = strip.FindForm();
            bool isMaximized = false;
            if (form != null) isMaximized = form.WindowState == System.Windows.Forms.FormWindowState.Maximized;

            // Get right most X position of the Quick Access Toolbar
            int right = 0, sysLeft = 0;
            Size qatSize = Size.Empty;
            for (int i = strip.QuickToolbarItems.Count - 1; i >= 0; i--)
            {
                BaseItem item = strip.QuickToolbarItems[i];
                if (!item.Visible || !item.Displayed)
                    continue;
                if (item is QatCustomizeItem) qatSize = item.DisplayRectangle.Size;
                if (item.ItemAlignment == eItemAlignment.Near && item.Visible && i > 0)
                {
                    if (rightToLeft)
                        right = item.DisplayRectangle.X;
                    else
                        right = item.DisplayRectangle.Right;
                    break;
                }
                else if (item.ItemAlignment == eItemAlignment.Far && item.Visible)
                {
                    if (rightToLeft)
                        sysLeft = item.DisplayRectangle.Right;
                    else
                        sysLeft = item.DisplayRectangle.X;
                }
            }
            
            if (strip.CaptionContainerItem is CaptionItemContainer && ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems != null)
            {
                if (rightToLeft)
                    right = ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems.DisplayRectangle.X;
                else
                    right = ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems.DisplayRectangle.Right;
                qatSize = ((CaptionItemContainer)strip.CaptionContainerItem).MoreItems.DisplayRectangle.Size;
            }

            Rectangle r = new Rectangle(right, 2, strip.CaptionContainerItem.WidthInternal - right - (strip.CaptionContainerItem.WidthInternal-sysLeft), strip.GetTotalCaptionHeight());
            strip.CaptionBounds = r;

            if (sysLeft > 0)
            {
                if (rightToLeft)
                    strip.SystemCaptionItemBounds = new Rectangle(r.X, r.Y, sysLeft, r.Height);
                else
                    strip.SystemCaptionItemBounds = new Rectangle(sysLeft, r.Y, strip.CaptionContainerItem.WidthInternal - sysLeft, r.Height);
            }

            if (right == 0 || r.Height <= 0 || r.Width <= 0)
                return;

            BaseItem startButton = strip.GetApplicationButton();
            if (startButton != null)
            {
                int startIndex = strip.QuickToolbarItems.IndexOf(startButton);
                if (strip.QuickToolbarItems.Count - 1 > startIndex)
                {
                    BaseItem firstItem = strip.QuickToolbarItems[startIndex + 1];
                    if (rightToLeft)
                    {
                        r.Width -= r.Right - firstItem.DisplayRectangle.Right;
                    }
                    else
                    {
                        r.Width -= firstItem.DisplayRectangle.X - r.X;
                        r.X = firstItem.DisplayRectangle.X;
                    }
                }
            }

            r.Height = ((CaptionItemContainer)strip.CaptionContainerItem).MaxItemHeight + 6;
            r.X = 0;
            r.Width = right;
            strip.QuickToolbarBounds = r;
        }