コード例 #1
0
        /// <summary>
        /// Paints background of docked bar.
        /// </summary>
        /// <param name="e">Context information</param>
        public override void PaintDockedBackground(ToolbarRendererEventArgs e)
        {
            Graphics g = e.Graphics;
            Bar bar = e.Bar;
            ItemPaintArgs pa = e.ItemPaintArgs;
            Rectangle r = e.Bounds;
            Rectangle backgroundBounds = r;
            backgroundBounds.Inflate(1, 1);

            ColorScheme cs = m_ColorTable.LegacyColors;
            if (bar.LayoutType == eLayoutType.DockContainer || bar.LayoutType == eLayoutType.TaskList)
            {
                if(bar.HasFocus)
                    DisplayHelp.FillRectangle(g, backgroundBounds, cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle);
                else
                    DisplayHelp.FillRectangle(g, backgroundBounds, cs.BarCaptionInactiveBackground, cs.BarCaptionInactiveBackground2, cs.BarCaptionInactiveBackgroundGAngle);
            }
            else if (bar.MenuBar)
            {
                DisplayHelp.FillRectangle(g, backgroundBounds, cs.MenuBarBackground, cs.MenuBarBackground2, cs.MenuBarBackgroundGradientAngle);
            }
            else if (bar.GrabHandleStyle != eGrabHandleStyle.ResizeHandle && bar.BarType != eBarType.StatusBar)
            {
                // Docked state
                if (bar.ItemsContainer.m_BackgroundColor.IsEmpty && bar.BackColor != Color.Transparent)
                {
                    if (bar.IsThemed)
                    {
                        Rectangle rb = new Rectangle(-bar.Location.X, -bar.Location.Y, bar.Parent.Width, bar.Parent.Height);
                        ThemeRebar theme = ((IThemeCache)bar).ThemeRebar;
                        theme.DrawBackground(g, ThemeRebarParts.Background, ThemeRebarStates.Normal, rb);
                    }
                    else
                    {
                        if (IsGradientBackground(bar))
                            DisplayHelp.FillRectangle(g, backgroundBounds, cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle, new float[] { 0, .12f, 1f }, new float[] { 0, .50f, 1f });
                        else
                            DisplayHelp.FillRectangle(g, backgroundBounds, cs.BarBackground);
                    }
                }
                else if (!bar.ItemsContainer.BackColor.IsEmpty)
                {
                    DisplayHelp.FillRectangle(g, backgroundBounds, bar.ItemsContainer.BackColor);
                }

                if (bar.Parent != null && bar.Parent.BackgroundImage != null && bar.Parent is DockSite)
                {
                    Rectangle rb = new Rectangle(-bar.Location.X, -bar.Location.Y, bar.Parent.Width, bar.Parent.Height);
                    DockSite site = bar.Parent as DockSite;
                    BarFunctions.PaintBackgroundImage(g, rb, site.BackgroundImage, site.BackgroundImagePosition, site.BackgroundImageAlpha);
                }
                else if(bar.BackgroundImage!=null)
                    BarFunctions.PaintBackgroundImage(g, r, bar.BackgroundImage, bar.BackgroundImagePosition, bar.BackgroundImageAlpha);

                if (!bar.IsThemed && bar.LayoutType == eLayoutType.Toolbar && bar.BackColor != Color.Transparent && pa!=null)
                {
                    using (Pen p = new Pen(pa.Colors.BarDockedBorder, 1))
                    {
                        g.DrawLine(p, 0, bar.Height - 1, bar.Width, bar.Height - 1);
                    }
                }
                else
                {
                    Rectangle border = r; // bar.ClientRectangle;
                    border.Inflate(-2, -2);
                    BarFunctions.DrawBorder(g, bar.DockedBorderStyle, border, bar.SingleLineColor);
                }
            }
            else
            {
                if (!bar.BackColor.IsEmpty && bar.ShouldSerializeBackColor())
                {
                    DisplayHelp.FillRectangle(g, r, bar.BackColor);
                }
                else
                {
                    Office2007BarColorTable colorTable = m_ColorTable.Bar;

                    Rectangle back = r;
                    if(!pa.CachedPaint)
                        back.Inflate(1, 1);

                    if (colorTable.ToolbarBottomBackground == null || colorTable.ToolbarBottomBackground.IsEmpty)
                    {
                        DisplayHelp.FillRectangle(g, back, colorTable.ToolbarTopBackground);
                    }
                    else
                    {
                        // Fill top background part
                        back.Height = (int)(back.Height * m_TopSplit);
                        back.Height++;
                        DisplayHelp.FillRectangle(g, back, colorTable.ToolbarTopBackground);
                        back.Height--;

                        // Fill bottom background part
                        back.Y += back.Height;
                        back.Height = r.Height - back.Height + 1;
                        DisplayHelp.FillRectangle(g, back, colorTable.ToolbarBottomBackground);
                    }

                    if (bar.BarType == eBarType.StatusBar && bar.Items.Count > 0 && bar.Items[bar.Items.Count - 1] is ItemContainer && e.ItemPaintArgs != null && e.ItemPaintArgs.CachedPaint)
                    {
                        ItemContainer ic = bar.Items[bar.Items.Count - 1] as ItemContainer;
                        if (ic.Visible && ic.BackgroundStyle.Class == ElementStyleClassKeys.Office2007StatusBarBackground2Key)
                        {
                            Rectangle bounds = new Rectangle(ic.Bounds.X, r.Y, ic.Bounds.Width, e.Bar.Height + 1);
                            if (e.ItemPaintArgs.RightToLeft)
                            {
                                bounds.Width += bounds.X;
                                bounds.X = 0;
                            }
                            else
                            {
                                bounds.X += e.ItemPaintArgs.ContainerControl.Left;
                                bounds.Width += r.Right - bounds.Right;
                            }
                            ElementStyleDisplay.Paint(new ElementStyleDisplayInfo(ic.BackgroundStyle, g, bounds));
                        }
                    }

                    if (bar.Parent != null && bar.Parent.BackgroundImage != null && bar.Parent is DockSite)
                    {
                        Rectangle backImageRect = new Rectangle(-bar.Location.X, -bar.Location.Y, bar.Parent.Width, bar.Parent.Height);
                        DockSite site = bar.Parent as DockSite;
                        BarFunctions.PaintBackgroundImage(g, backImageRect, site.BackgroundImage, site.BackgroundImagePosition, site.BackgroundImageAlpha);
                    }
                    else if (bar.BackgroundImage != null)
                        BarFunctions.PaintBackgroundImage(g, bar.ClientRectangle, bar.BackgroundImage, bar.BackgroundImagePosition, bar.BackgroundImageAlpha);

                    if (!colorTable.ToolbarBottomBorder.IsEmpty && bar.BarType != eBarType.StatusBar ||
                        !colorTable.StatusBarTopBorder.IsEmpty && bar.BarType == eBarType.StatusBar)
                    {
                        if (bar.BarType == eBarType.StatusBar)
                        {
                            using (Pen pen = new Pen(colorTable.StatusBarTopBorder, 1))
                                g.DrawLine(pen, r.X, r.Y, r.Right, r.Y);
                            if (!colorTable.StatusBarTopBorderLight.IsEmpty)
                            {
                                using (Pen pen = new Pen(colorTable.StatusBarTopBorderLight, 1))
                                    g.DrawLine(pen, r.X, r.Y + 1, r.Right, r.Y + 1);
                            }
                        }
                        else
                        {
                            using (Pen pen = new Pen(colorTable.ToolbarBottomBorder, 1))
                                g.DrawLine(pen, r.X, r.Bottom - 1, r.Right, r.Bottom - 1);
                        }
                    }
                }
            }
            if (pa != null && !pa.CachedPaint)
                bar.PaintGrabHandle(pa);
        }
コード例 #2
0
        /// <summary>
        /// Paints background of floating bar.
        /// </summary>
        /// <param name="e">Context information</param>
        public override void PaintFloatingBackground(ToolbarRendererEventArgs e)
        {
            Graphics g = e.Graphics;
            Bar bar = e.Bar;
            ItemPaintArgs pa = e.ItemPaintArgs;
            Rectangle r = e.Bounds;

            ColorScheme cs = m_ColorTable.LegacyColors;
            DisplayHelp.FillRectangle(g, r, cs.BarBackground, cs.BarBackground2, cs.BarBackgroundGradientAngle, new float[] { 0, .12f, 1f }, new float[] { 0, .50f, 1f });

            //Office2007BarColorTable colorTable = m_ColorTable.Bar;
            //Rectangle back = r;
            //// Fill top background part
            //back.Height = (int)(back.Height * m_TopSplit);
            //DisplayHelp.FillRectangle(g, back, colorTable.ToolbarTopBackground);

            //// Fill bottom background part
            //back.Y += back.Height;
            //back.Height = r.Height - back.Height;
            //DisplayHelp.FillRectangle(g, back, colorTable.ToolbarBottomBackground);

            if (bar.BackgroundImage != null)
                BarFunctions.PaintBackgroundImage(g, bar.ClientRectangle, bar.BackgroundImage, bar.BackgroundImagePosition, bar.BackgroundImageAlpha);
        }
コード例 #3
0
        /// <summary>
        /// Paints background of popup bar.
        /// </summary>
        /// <param name="e">Context information</param>
        public override void PaintPopupBackground(ToolbarRendererEventArgs e)
        {
            Graphics g = e.Graphics;
            Bar bar = e.Bar;
            ItemPaintArgs pa = e.ItemPaintArgs;
            Office2007BarColorTable colorTable = m_ColorTable.Bar;
            int cornerSize = bar.CornerSize;
            Rectangle r = e.Bounds;

            DisplayHelp.FillRectangle(g, r, colorTable.PopupToolbarBackground.Start, colorTable.PopupToolbarBackground.End, colorTable.PopupToolbarBackground.GradientAngle);

            if (bar.BackgroundImage != null)
                BarFunctions.PaintBackgroundImage(g, bar.ClientRectangle, bar.BackgroundImage, bar.BackgroundImagePosition, bar.BackgroundImageAlpha);

            bar.PaintSideBar(g);

            Rectangle borderRectangle = r;

            if (bar.DisplayShadow && !bar.AlphaShadow)
                borderRectangle = new Rectangle(0, 0, bar.ClientSize.Width - 2, bar.ClientSize.Height - 2);

            using (Pen p = new Pen(colorTable.PopupToolbarBorder, 1))
                DisplayHelp.DrawRoundedRectangle(g, p, borderRectangle, cornerSize);

            if (bar.DisplayShadow && !bar.AlphaShadow)
            {
                // Shadow
                Point[] pt = new Point[3];
                pt[0].X = 2;
                pt[0].Y = r.Height - 1;
                pt[1].X = r.Width - 1;
                pt[1].Y = r.Height - 1;
                pt[2].X = r.Width - 1;
                pt[2].Y = 2;
                using (Pen p = new Pen(SystemColors.ControlDark, 2))
                    g.DrawLines(p, pt);
            }
        }
コード例 #4
0
        protected virtual void PaintCaptionParts(Graphics g)
        {
            if (m_RibbonControl == null || !m_RibbonControl.CaptionVisible) return;
            if (m_DisplayRectangleReductionHorizontal <= 2)
                return;
            RibbonControlRendererEventArgs e = new RibbonControlRendererEventArgs(g, m_RibbonControl, this.IsGlassEnabled);
            e.ItemPaintArgs = m_RibbonControl.RibbonStrip.GetItemPaintArgs(g);
            BaseRenderer r = m_RibbonControl.RibbonStrip.GetRenderer();
            if (r == null) return;
            Region oldClip = g.Clip;
            Rectangle formRect = new Rectangle(1, 1, this.Width - 3, this.Height - 3);
            eDotNetBarStyle effectiveStyle = m_RibbonControl.EffectiveStyle;
            if (effectiveStyle == eDotNetBarStyle.Office2010)
                formRect = new Rectangle(2, 2, this.Width - 5, this.Height - 4);
            else if (effectiveStyle == eDotNetBarStyle.Metro)
                formRect = new Rectangle(1, 1, this.Width - 3, this.Height - 3);

            Region formRegion = GetRegion(formRect);
            int part = m_DisplayRectangleReductionHorizontal;
            Rectangle excludeRect = new Rectangle(formRect.X, m_RibbonControl.RibbonStrip.CaptionBounds.Height + 5,
                formRect.Width, this.Height - (m_RibbonControl.RibbonStrip.CaptionBounds.Height + 2));

            g.SetClip(formRegion, CombineMode.Replace);
            g.SetClip(excludeRect, CombineMode.Exclude);
            g.TranslateTransform(1, 1);
            r.DrawRibbonControlBackground(e);
            r.DrawQuickAccessToolbarBackground(e); // Will not be needed with latest Office 2007 style

            if (effectiveStyle == eDotNetBarStyle.Metro)
            {
                if (m_RibbonControl.GetApplicationButton() != null)
                {
                    ButtonItem appButton = m_RibbonControl.GetApplicationButton() as ButtonItem;
                    g.TranslateTransform(-1, 0);
                    if (appButton != null && appButton.Displayed)
                    {
                        g.SetClip(formRegion, CombineMode.Replace);
                        r.DrawButtonItem(new ButtonItemRendererEventArgs(g, appButton, m_RibbonControl.RibbonStrip.GetItemPaintArgs(g)));
                        if (m_RibbonControl.Expanded)
                        {
                            g.TranslateTransform(0, 1);
                            r.DrawButtonItem(new ButtonItemRendererEventArgs(g, appButton, m_RibbonControl.RibbonStrip.GetItemPaintArgs(g)));
                        }
                    }
                }
                g.ResetTransform();
                if (m_RibbonControl.TabGroups.Count > 0)
                {
                    g.SetClip(formRegion, CombineMode.Replace);
                    g.TranslateTransform(m_RibbonControl.Left, 0);
                    m_RibbonControl.RibbonStrip.PaintTabGroups(m_RibbonControl.RibbonStrip.GetItemPaintArgs(g));
                    g.ResetTransform();
                }
                Office2007ColorTable table = ((Office2007Renderer)r).ColorTable;
                if (m_RibbonControl.Expanded && !table.RibbonControl.OuterBorder.Start.IsEmpty)
                {
                    using (Pen pen = new Pen(table.RibbonControl.OuterBorder.Start))
                    {
                        g.DrawLine(pen, this.Width - 5, m_RibbonControl.RibbonStrip.Height, this.Width - 1, m_RibbonControl.RibbonStrip.Height);
                        g.DrawLine(pen, this.Width - 5, m_RibbonControl.Height - 2, this.Width - 1, m_RibbonControl.Height - 2);
                        g.DrawLine(pen, 1, m_RibbonControl.Height - 2, 5, m_RibbonControl.Height - 2);
                    }
                }
            }

            g.ResetTransform();

            // Draw Status bar if any...
            Bar statusBar = GetStatusBar();
            if (statusBar != null && BarFunctions.IsOffice2007Style(statusBar.Style) && !statusBar.IsThemed)
            {
                r = statusBar.GetRenderer();
                if (r != null)
                {
                    g.SetClip(formRegion, CombineMode.Replace);
                    //g.FillRectangle(Brushes.Red, new Rectangle(0, statusBar.Top, this.Width, statusBar.Height + 4));

                    ToolbarRendererEventArgs te = new ToolbarRendererEventArgs(statusBar, g, new Rectangle(0, statusBar.Top, this.Width, statusBar.Height + 4));
                    te.ItemPaintArgs = statusBar.GetItemPaintArgs(g);
                    te.ItemPaintArgs.CachedPaint = true;
                    r.DrawToolbarBackground(te);
                }
            }

            g.Clip = oldClip;
            if (oldClip != null) oldClip.Dispose();
            formRegion.Dispose();
        }
コード例 #5
0
        protected void PaintDotNet(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            SmoothingMode sm = g.SmoothingMode;
            TextRenderingHint th = g.TextRenderingHint;
            RenderBarEventArgs re = null;

            if (m_AntiAlias)
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                g.TextRenderingHint = DisplayHelp.AntiAliasTextRenderingHint;
            }

            m_SystemButtons.CustomizeButtonRect = Rectangle.Empty;
            m_SystemButtons.CloseButtonRect = Rectangle.Empty;
            m_SystemButtons.AutoHideButtonRect = Rectangle.Empty;
            m_SystemButtons.CaptionButtonRect = Rectangle.Empty;
            ColorScheme cs = this.GetColorScheme();

            ItemPaintArgs pa = GetItemPaintArgs(g);
            pa.ClipRectangle = e.ClipRectangle;
            Pen p;
            if (m_BarState == eBarState.Popup)
                p = new Pen(pa.Colors.BarPopupBorder, 1);
            else
                p = new Pen(pa.Colors.BarFloatingBorder);

            if (this.DisplayShadow && !this.AlphaShadow && m_ParentItem != null && !BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
                SetupRegion();

            if (m_BarState == eBarState.Popup)
            {
                re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
                OnPreRender(re);
                if (!re.Cancel)
                {
                    if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle) && GetRenderer() != null)
                    {
                        ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
                        tre.ItemPaintArgs = pa;
                        GetRenderer().DrawPopupToolbarBackground(tre);
                    }
                    else
                    {
                        using (SolidBrush brush = new SolidBrush(pa.Colors.BarPopupBackground))
                            g.FillRectangle(brush, this.DisplayRectangle);
                        PaintBackgroundImage(pa.Graphics);

                        PaintSideBar(g);

                        Rectangle borderRectangle = this.ClientRectangle;
                        if (this.DisplayShadow && !this.AlphaShadow)
                            borderRectangle = new Rectangle(0, 0, this.ClientSize.Width - 2, this.ClientSize.Height - 2);

                        if (m_ParentItem != null && BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle))
                            DisplayHelp.DrawRoundedRectangle(g, p, borderRectangle, m_CornerSize);
                        else
                            NativeFunctions.DrawRectangle(g, p, borderRectangle);

                        if (this.DisplayShadow && !this.AlphaShadow)
                        {
                            // Shadow
                            p.Dispose();
                            p = new Pen(SystemColors.ControlDark, 2);
                            Point[] pt = new Point[3];
                            pt[0].X = 2;
                            pt[0].Y = this.ClientSize.Height - 1;
                            pt[1].X = this.ClientSize.Width - 1;
                            pt[1].Y = this.ClientSize.Height - 1;
                            pt[2].X = this.ClientSize.Width - 1;
                            pt[2].Y = 2;
                            g.DrawLines(p, pt);
                        }
                        if (m_ParentItem != null && !BarFunctions.IsOffice2007Style(m_ParentItem.EffectiveStyle) && m_ParentItem is ButtonItem && m_ParentItem.Displayed)
                        {
                            // Determine where to draw the line based on parent position
                            if (m_ParentItemScreenPos.Y < this.Location.Y)
                            {
                                Point p1 = new Point((m_ParentItemScreenPos.X - this.Location.X) + 1, 0);
                                Point p2 = new Point(p1.X + m_ParentItem.WidthInternal - 5, 0);
                                DisplayHelp.DrawLine(g, p1, p2, pa.Colors.ItemExpandedBackground, 1);
                                //g.DrawLine(new Pen(pa.Colors.ItemExpandedBackground, 1), p1, p2);
                            }
                        }
                    }
                }
            }
            else if (m_BarState == eBarState.Floating)
            {
                bool drawCaptionText = true;

                re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
                OnPreRender(re);
                if (!re.Cancel)
                {
                    if (BarFunctions.IsOffice2007Style(this.Style) && this.GetRenderer() != null)
                    {
                        ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
                        tre.ItemPaintArgs = pa;
                        this.GetRenderer().DrawToolbarBackground(tre);
                    }
                    else
                    {
                        sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.Default;
                        if (this.MenuBar)
                            DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.MenuBarBackground, pa.Colors.MenuBarBackground2, pa.Colors.MenuBarBackgroundGradientAngle);
                        else
                            DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);

                        PaintBackgroundImage(pa.Graphics);
                        g.SmoothingMode = sm;
                    }
                }

                Rectangle r = new Rectangle(0, 0, this.Width, this.Height);

                ThemeWindow theme = null;
                ThemeWindowParts part = ThemeWindowParts.SmallFrameLeft;
                ThemeWindowStates state = ThemeWindowStates.FrameActive;

                re = new RenderBarEventArgs(this, g, eBarRenderPart.Caption, Rectangle.Empty);

                if (this.DrawThemedCaption)
                {
                    re.Bounds = new Rectangle(0, 0, this.Width, m_ThemeWindowMargins.Top + 1);
                    OnPreRender(re);
                    if (!re.Cancel)
                    {
                        theme = this.ThemeWindow;
                        if (this.LayoutType == eLayoutType.DockContainer && !m_HasFocus)
                            state = ThemeWindowStates.FrameInactive;

                        theme.DrawBackground(g, part, state, new Rectangle(0, 0, m_ThemeWindowMargins.Left, this.Height));
                        part = ThemeWindowParts.SmallFrameRight;
                        theme.DrawBackground(g, part, state, new Rectangle(this.Width - m_ThemeWindowMargins.Right, 0, m_ThemeWindowMargins.Left, this.Height));
                        part = ThemeWindowParts.SmallFrameBottom;
                        theme.DrawBackground(g, part, state, new Rectangle(0, this.Height - m_ThemeWindowMargins.Bottom, this.Width, m_ThemeWindowMargins.Bottom));

                        if (this.LayoutType == eLayoutType.DockContainer && !m_HasFocus)
                            state = ThemeWindowStates.CaptionInactive;
                        part = ThemeWindowParts.SmallCaption;
                    }
                    r = new Rectangle(0, 0, this.Width, m_ThemeWindowMargins.Top + 1);
                    theme.DrawBackground(g, part, state, r);
                    r.Offset(0, 1);
                }
                else if (m_GrabHandleStyle == eGrabHandleStyle.Caption && this.LayoutType == eLayoutType.DockContainer && this.Style == eDotNetBarStyle.Office2000)
                {
                    Rectangle rback = new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight());
                    re.Bounds = rback;
                    OnPreRender(re);
                    if (!re.Cancel)
                    {
                        ControlPaint.DrawBorder3D(g, r, Border3DStyle.Raised, Border3DSide.All);
                        eDrawCaption flags = eDrawCaption.DC_SMALLCAP | eDrawCaption.DC_GRADIENT | eDrawCaption.DC_TEXT;
                        if (m_HasFocus) flags |= eDrawCaption.DC_ACTIVE;
                        IntPtr hdc = g.GetHdc();
                        NativeFunctions.RECT rect = new NativeFunctions.RECT(rback.X, rback.Y, rback.Right, rback.Bottom);
                        try
                        {
                            NativeFunctions.DrawCaption(this.Handle, hdc, ref rect, flags);
                        }
                        finally
                        {
                            g.ReleaseHdc(hdc);
                        }
                    }
                    drawCaptionText = false;
                    r = rback;
                }
                else
                {
                    Rectangle rback = new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight());
                    re.Bounds = rback;
                    OnPreRender(re);

                    if (!re.Cancel)
                    {
                        Pen p1 = new Pen(pa.Colors.BarFloatingBorder, 1);
                        NativeFunctions.DrawRectangle(g, p, r);
                        r.Inflate(-1, -1);
                        NativeFunctions.DrawRectangle(g, p, r);

                        p1.Dispose();
                        p1 = new Pen(pa.Colors.BarFloatingBorder, 1);
                        g.DrawLine(p1, 1, 2, 2, 2);
                        g.DrawLine(p1, this.Width - 3, 2, this.Width - 2, 2);
                        g.DrawLine(p1, 1, this.Height - 3, 2, this.Height - 3);
                        g.DrawLine(p1, this.Width - 3, this.Height - 3, this.Width - 2, this.Height - 3);
                        p1.Dispose();
                        p1 = null;

                        if (this.GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane)
                        {
                            sm = g.SmoothingMode;
                            g.SmoothingMode = SmoothingMode.Default;

                            if (m_CaptionBackColor.IsEmpty)
                            {
                                if (this.LayoutType == eLayoutType.Toolbar || m_HasFocus)
                                    DisplayHelp.FillRectangle(g, rback, pa.Colors.BarCaptionBackground, pa.Colors.BarCaptionBackground2, pa.Colors.BarCaptionBackgroundGradientAngle);
                                else
                                    DisplayHelp.FillRectangle(g, rback, pa.Colors.BarCaptionInactiveBackground, pa.Colors.BarCaptionInactiveBackground2, pa.Colors.BarCaptionInactiveBackgroundGAngle);
                            }
                            else
                                DisplayHelp.FillRectangle(g, new Rectangle(3, 3, this.Width - 6, GetGrabHandleCaptionHeight()), m_CaptionBackColor, Color.Empty);

                            g.SmoothingMode = sm;
                        }
                    }
                    r = rback;
                }

                r.Inflate(-1, -1);

                if (this.GrabHandleStyle != eGrabHandleStyle.CaptionTaskPane)
                {
                    if (this.CanHideResolved)
                    {
                        m_SystemButtons.CloseButtonRect = new Rectangle(r.Right - (m_SystemButtons.ButtonSize.Width + 3), r.Y + (r.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.CloseButton, m_SystemButtons.CloseButtonRect);
                        OnPreRender(re);
                        m_SystemButtons.CloseButtonRect = re.Bounds;
                        r.Width -= (m_SystemButtons.CloseButtonRect.Width + 3);
                        if (!re.Cancel)
                            PaintCloseButton(pa);
                    }
                    if (this.ShowCustomizeMenuButton)
                    {
                        m_SystemButtons.CustomizeButtonRect = new Rectangle(r.Right - (m_SystemButtons.ButtonSize.Width + 1), r.Y + (r.Height - m_SystemButtons.ButtonSize.Height) / 2, m_SystemButtons.ButtonSize.Width, m_SystemButtons.ButtonSize.Height);
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.CustomizeButton, m_SystemButtons.CustomizeButtonRect);
                        OnPreRender(re);
                        m_SystemButtons.CustomizeButtonRect = re.Bounds;
                        r.Width -= (m_SystemButtons.CustomizeButtonRect.Width + 2);
                        if (!re.Cancel)
                            PaintCustomizeButton(pa);
                    }
                    r.X += 2;
                    r.Width -= 2;
                    if (r.Width > 0 && drawCaptionText)
                    {
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.CaptionText, r);
                        OnPreRender(re);
                        if (!re.Cancel)
                        {
                            System.Drawing.Font objFont = null;
                            try
                            {
                                objFont = new Font(this.Font, FontStyle.Bold);
                            }
                            catch
                            {
                                objFont = SystemFonts.MenuFont; // (Font)System.Windows.Forms.SystemInformation.MenuFont.Clone();
                            }
                            eTextFormat sf = eTextFormat.Default | eTextFormat.EndEllipsis | eTextFormat.SingleLine | eTextFormat.VerticalCenter;
                            if (m_CaptionForeColor.IsEmpty)
                            {
                                if (this.DrawThemedCaption)
                                {
                                    if (m_HasFocus)
                                        state = ThemeWindowStates.CaptionActive;
                                    else
                                        state = ThemeWindowStates.CaptionInactive;
                                    r.Y += 1;
                                    //theme.DrawText(g, this.Text, objFont, r, part, state, ThemeTextFormat.Left | ThemeTextFormat.VCenter);
                                }
                                //else
                                TextDrawing.DrawString(g, this.Text, objFont, ((m_HasFocus || this.LayoutType == eLayoutType.Toolbar) ? pa.Colors.BarCaptionText : pa.Colors.BarCaptionInactiveText), r, sf);
                            }
                            else
                                TextDrawing.DrawString(g, this.Text, objFont, m_CaptionForeColor, r, sf);
                            objFont.Dispose();
                            objFont = null;
                        }
                    }
                }
                else
                {
                    this.PaintGrabHandle(pa);
                }
            }
            else if (m_BarState == eBarState.Docked && BarFunctions.IsOffice2007Style(this.Style) && this.GetRenderer() != null && (!this.IsThemed || this.MenuBar))
            {
                re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.DisplayRectangle);
                OnPreRender(re);
                if (!re.Cancel && this.BackColor != Color.Transparent)
                {
                    ToolbarRendererEventArgs tre = new ToolbarRendererEventArgs(this, g, this.DisplayRectangle);
                    tre.ItemPaintArgs = pa;
                    this.GetRenderer().DrawToolbarBackground(tre);
                }
                else
                    PaintGrabHandle(pa);
            }
            else
            {
                p.Dispose();
                p = null;
                bool drawBorder = true;
                // Docked state
                if (m_ItemContainer.m_BackgroundColor.IsEmpty && this.BackColor != Color.Transparent)
                {
                    if (this.IsThemed)
                    {
                        Rectangle r = new Rectangle(-this.Location.X, -this.Location.Y, this.Parent.Width, this.Parent.Height);
                        ThemeRebar theme = this.ThemeRebar;
                        theme.DrawBackground(g, ThemeRebarParts.Background, ThemeRebarStates.Normal, r);
                    }
                    else
                    {
                        sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.Default;
                        re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.ClientRectangle);
                        OnPreRender(re);
                        if (!re.Cancel)
                        {
                            if (this.MenuBar)
                            {
                                if (!pa.Colors.MenuBarBackground2.IsEmpty && pa.Colors.MenuBarBackground2.A > 0)
                                {
                                    System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(this.ClientRectangle, pa.Colors.MenuBarBackground, pa.Colors.MenuBarBackground2, pa.Colors.MenuBarBackgroundGradientAngle);
                                    g.FillRectangle(gradient, this.ClientRectangle);
                                    gradient.Dispose();
                                }
                                else if (IsGradientStyle && this.Parent != null && !pa.Colors.DockSiteBackColor2.IsEmpty && !pa.Colors.DockSiteBackColor.IsEmpty)
                                {
                                    System.Drawing.Drawing2D.LinearGradientBrush gradient = BarFunctions.CreateLinearGradientBrush(new Rectangle(-this.Left, -this.Top, this.Parent.Width, this.Parent.Height), pa.Colors.DockSiteBackColor, pa.Colors.DockSiteBackColor2, 0f);
                                    g.FillRectangle(gradient, -this.Left, -this.Top, this.Parent.Width, this.Parent.Height);
                                    gradient.Dispose();
                                }
                                else
                                {
                                    using (SolidBrush brush = new SolidBrush(pa.Colors.MenuBarBackground))
                                        g.FillRectangle(brush, this.DisplayRectangle);
                                }
                            }
                            else
                            {
                                if (this.Style == eDotNetBarStyle.VS2005 && this.LayoutType == eLayoutType.DockContainer && !this.BackColor.IsEmpty)
                                {
                                    DisplayHelp.FillRectangle(g, this.ClientRectangle, this.BackColor, Color.Empty);
                                }
                                else if (this.GradientBackground)
                                    DisplayHelp.FillRectangle(g, this.ClientRectangle, pa.Colors.BarBackground, pa.Colors.BarBackground2, pa.Colors.BarBackgroundGradientAngle);
                                else
                                {
                                    using (SolidBrush brush = new SolidBrush(pa.Colors.BarBackground))
                                        g.FillRectangle(brush, this.ClientRectangle);
                                }
                            }
                        }
                        else
                            drawBorder = false;
                        g.SmoothingMode = sm;
                    }
                }
                else if (!m_ItemContainer.BackColor.IsEmpty)
                {
                    sm = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.Default;
                    re = new RenderBarEventArgs(this, g, eBarRenderPart.Background, this.DisplayRectangle);
                    OnPreRender(re);
                    if (!re.Cancel)
                    {
                        using (SolidBrush brush = new SolidBrush(m_ItemContainer.BackColor))
                            g.FillRectangle(brush, this.DisplayRectangle);
                    }
                    else
                        drawBorder = false;
                    g.SmoothingMode = sm;
                }

                if (this.Parent != null && this.Parent.BackgroundImage != null && this.Parent is DockSite)
                {
                    Rectangle r = new Rectangle(-this.Location.X, -this.Location.Y, this.Parent.Width, this.Parent.Height);
                    DockSite site = this.Parent as DockSite;
                    BarFunctions.PaintBackgroundImage(g, r, site.BackgroundImage, site.BackgroundImagePosition, site.BackgroundImageAlpha);
                }
                else
                    PaintBackgroundImage(pa.Graphics);

                if (drawBorder)
                {
                    if (IsGradientStyle && !this.IsThemed && this.LayoutType == eLayoutType.Toolbar && !this.MenuBar && this.BarType == eBarType.Toolbar && this.BackColor != Color.Transparent)
                    {
                        if (p != null) p.Dispose();
                        p = new Pen(pa.Colors.BarDockedBorder, 1);
                        g.DrawLine(p, 0, this.Height - 1, this.Width, this.Height - 1);
                        p.Dispose();
                        p = null;
                    }
                    else
                    {
                        Rectangle border = this.ClientRectangle;
                        border.Inflate(-2, -2);
                        BarFunctions.DrawBorder(g, m_DockedBorder, border, m_SingleLineColor);
                    }
                }
                PaintGrabHandle(pa);
            }
            m_ItemContainer.Paint(pa);
            if (m_BarType == eBarType.StatusBar && this.GrabHandleStyle == eGrabHandleStyle.ResizeHandle)
            {
                PaintGrabHandle(pa);
            }
            if (p != null) p.Dispose();
            g.SmoothingMode = sm;
            g.TextRenderingHint = th;

            if (HasPostRender)
            {
                re = new RenderBarEventArgs(this, g, eBarRenderPart.All, this.ClientRectangle);
                OnPostRender(re);
            }
        }
コード例 #6
0
 /// <summary>
 /// Paints background of popup bar.
 /// </summary>
 /// <param name="e">Context information</param>
 public virtual void PaintPopupBackground(ToolbarRendererEventArgs e)
 {
 }
コード例 #7
0
 /// <summary>
 /// Paints background of floating bar.
 /// </summary>
 /// <param name="e">Context information</param>
 public virtual void PaintFloatingBackground(ToolbarRendererEventArgs e)
 {
 }
コード例 #8
0
 /// <summary>
 /// Paints background of docked bar.
 /// </summary>
 /// <param name="e">Context information</param>
 public virtual void PaintDockedBackground(ToolbarRendererEventArgs e)
 {
 }