Esempio n. 1
0
        private void FillMenuIconGradient(
            GraphicsPath XFillPath,
            Graphics g,
            List <Color> mix
            )
        {
            using (XAntiAlias xaa = new XAntiAlias(g))
            {
                using (LinearGradientBrush lgb = new LinearGradientBrush
                                                     (XFillPath.GetBounds(),
                                                     mix[0],
                                                     mix[4],
                                                     LinearGradientMode.Vertical))
                {
                    lgb.InterpolationColors = XCoolFormHelper.ColorMix(mix, false);

                    g.FillPath(
                        lgb,
                        XFillPath
                        );
                }
            }
        }
Esempio n. 2
0
        public void RenderTitleBarButtonsBox(
            Rectangle rcBox,
            Graphics g,
            int lSinglePosX,
            int lSinglePosY
            )
        {
            using (XAntiAlias xaa = new XAntiAlias(g))
            {
                int lBtnWidth  = 0;
                int lBtnHeight = 0;
                foreach (XTitleBarButton btn in m_xtbButtons)
                {
                    if (btn.ButtonStyle == XTitleBarButton.XTitleBarButtonStyle.MacStyle)
                    {
                        m_bShouldRenderButtonBox = false;
                    }

                    lBtnWidth  = btn.XButtonWidth;
                    lBtnHeight = btn.XButtonHeight;
                }
                int lX = rcBox.Right - lBtnWidth;
                int lY = rcBox.Bottom - lBtnHeight;

                if (m_bShouldRenderButtonBox)
                {
                    using (GraphicsPath XButtonBox = BuildTitleBarButtonsBox(rcBox))
                    {
                        switch (m_eButtonBoxFill)
                        {
                        case XButtonBoxFill.ColorMix:
                            using (LinearGradientBrush lgb = new LinearGradientBrush(
                                       rcBox,
                                       m_ButtonBoxColors[0],
                                       m_ButtonBoxColors[4],
                                       LinearGradientMode.Vertical))
                            {
                                lgb.InterpolationColors = XCoolFormHelper.ColorMix
                                                          (
                                    m_ButtonBoxColors,
                                    false
                                                          );

                                g.FillPath(
                                    lgb,
                                    XButtonBox
                                    );
                            }
                            break;

                        case XButtonBoxFill.TitleBarRectangleRendering:
                            RectangleF rcDownRect = XButtonBox.GetBounds();
                            RectangleF rcUpRect   = XButtonBox.GetBounds();
                            g.SetClip(XButtonBox);
                            rcUpRect.Height /= 2;
                            using (LinearGradientBrush lgbUpperRect = new LinearGradientBrush(
                                       rcUpRect,
                                       m_clrUpperFillStart,
                                       m_clrUpperFillEnd,
                                       LinearGradientMode.Vertical
                                       ))
                            {
                                lgbUpperRect.WrapMode = WrapMode.TileFlipY;
                                g.FillRectangle(
                                    lgbUpperRect,
                                    rcUpRect
                                    );
                            }

                            rcDownRect.Height = rcDownRect.Height / 2;
                            rcDownRect.Y      = rcUpRect.Bottom;
                            using (LinearGradientBrush lgbDwnRect = new LinearGradientBrush(
                                       rcDownRect,
                                       m_clrFillStart,
                                       m_clrFillEnd,
                                       LinearGradientMode.Vertical
                                       ))
                            {
                                g.FillRectangle(
                                    lgbDwnRect,
                                    rcDownRect
                                    );
                            }

                            g.ResetClip();
                            break;
                        }


                        #region Draw button separators
                        g.DrawLine(
                            new Pen(m_clrButtonBoxOuter),
                            rcBox.Right - lBtnWidth,
                            rcBox.Bottom,
                            rcBox.Right - lBtnWidth,
                            rcBox.Top + 1);
                        g.DrawLine(
                            new Pen(m_clrButtonBoxInner),
                            rcBox.Right - lBtnWidth - 1,
                            rcBox.Bottom,
                            rcBox.Right - lBtnWidth - 1,
                            rcBox.Top + 1);
                        g.DrawLine(
                            new Pen(m_clrButtonBoxOuter),
                            rcBox.Right - lBtnWidth * 2,
                            rcBox.Bottom - 2,
                            rcBox.Right - lBtnWidth * 2,
                            rcBox.Top + 1);
                        g.DrawLine(
                            new Pen(m_clrButtonBoxInner),
                            rcBox.Right - lBtnWidth * 2 - 1,
                            rcBox.Bottom - 2,
                            rcBox.Right - lBtnWidth * 2 - 1,
                            rcBox.Top + 1);
                        #endregion

                        #region Render buttons
                        g.SetClip(XButtonBox);
                        foreach (XTitleBarButton btn in m_xtbButtons)
                        {
                            btn.XButtonLeft = lX;
                            btn.XButtonTop  = lY;

                            btn.RenderTitleBarButton(
                                btn.XButtonLeft,
                                btn.XButtonTop,
                                g,
                                XButtonBox
                                );
                            lX -= btn.XButtonWidth + 1;
                        }
                        g.ResetClip();
                        #endregion


                        g.DrawPath(
                            new Pen(m_clrButtonBoxOuter),
                            XButtonBox
                            );

                        DrawInnerTitleBarBoxBorder(g, rcBox, m_clrButtonBoxInner);
                    }
                }
                else
                {
                    int lSP = lSinglePosX;
                    foreach (XTitleBarButton btn in m_xtbButtons)
                    {
                        btn.XButtonHeight = 13;
                        btn.XButtonWidth  = 13;
                        btn.XButtonLeft   = lSP;
                        btn.XButtonTop    = lSinglePosY;

                        btn.RenderTitleBarButton(
                            btn.XButtonLeft,
                            btn.XButtonTop,
                            g,
                            null
                            );
                        lSP -= btn.XButtonWidth + 4;
                    }
                }
            }
        }
Esempio n. 3
0
        private void FillTitleBar(
            Graphics g,
            Rectangle rcTitleBar
            )
        {
            GraphicsPath XTitleBarPath = new GraphicsPath();

            XTitleBarPath = BuildTitleBarShape(rcTitleBar);
            using (XAntiAlias xaa = new XAntiAlias(g))
            {
                #region Fill titlebar
                switch (m_eTitleBarFill)
                {
                case XTitleBarFill.AdvancedRendering:
                    using (LinearGradientBrush lgb = new LinearGradientBrush(
                               rcTitleBar,
                               m_TitleBarMix[0],
                               m_TitleBarMix[4],
                               LinearGradientMode.Vertical))
                    {
                        lgb.InterpolationColors = XCoolFormHelper.ColorMix(
                            m_TitleBarMix,
                            true
                            );

                        g.FillPath(
                            lgb,
                            XTitleBarPath
                            );
                    }


                    #region Draw titlebar glow
                    using (GraphicsPath XGlow = new GraphicsPath())
                    {
                        XGlow.AddEllipse(
                            rcTitleBar.Left,
                            rcTitleBar.Bottom / 2 + 4,
                            rcTitleBar.Width,
                            rcTitleBar.Height
                            );

                        using (PathGradientBrush pgb = new PathGradientBrush(XGlow))
                        {
                            pgb.CenterColor    = Color.White;
                            pgb.SurroundColors = new Color[] { Color.FromArgb(0, 229, 121, 13) };

                            g.SetClip(XTitleBarPath);
                            g.FillPath(
                                pgb,
                                XGlow
                                );
                            g.ResetClip();
                        }
                    }
                    #endregion

                    break;

                case XTitleBarFill.Texture:
                    if (m_TitleBarTexture != null)
                    {
                        using (TextureBrush tb = new TextureBrush(m_TitleBarTexture))
                        {
                            g.FillPath(
                                tb,
                                XTitleBarPath
                                );
                        }
                    }
                    break;

                case XTitleBarFill.LinearRendering:
                    RectangleF rcLinearFill = XTitleBarPath.GetBounds();
                    g.SetClip(XTitleBarPath);
                    using (LinearGradientBrush lgbLinearFill = new LinearGradientBrush(
                               rcLinearFill,
                               m_clrFillStart,
                               m_clrFillEnd,
                               LinearGradientMode.Vertical
                               ))
                    {
                        g.FillRectangle(
                            lgbLinearFill,
                            rcLinearFill
                            );
                    }

                    g.ResetClip();
                    break;

                case XTitleBarFill.UpperGlow:
                    RectangleF rcGlow = XTitleBarPath.GetBounds();
                    g.SetClip(XTitleBarPath);
                    rcGlow.Height /= 2;
                    using (LinearGradientBrush lgbUpperGlow = new LinearGradientBrush(
                               rcGlow,
                               m_clrUpperFillStart,
                               m_clrUpperFillEnd,
                               LinearGradientMode.Vertical
                               ))
                    {
                        g.FillRectangle(
                            lgbUpperGlow,
                            rcGlow
                            );
                    }

                    g.ResetClip();
                    break;

                case XTitleBarFill.RectangleRendering:
                    RectangleF rcDownRect = XTitleBarPath.GetBounds();
                    RectangleF rcUpRect   = XTitleBarPath.GetBounds();
                    g.SetClip(XTitleBarPath);
                    rcUpRect.Height /= 2;
                    using (LinearGradientBrush lgbUpperRect = new LinearGradientBrush(
                               rcUpRect,
                               m_clrUpperFillStart,
                               m_clrUpperFillEnd,
                               LinearGradientMode.Vertical
                               ))
                    {
                        lgbUpperRect.WrapMode = WrapMode.TileFlipY;
                        g.FillRectangle(
                            lgbUpperRect,
                            rcUpRect
                            );
                    }

                    rcDownRect.Height = rcDownRect.Height / 2;
                    rcDownRect.Y      = rcUpRect.Bottom;
                    using (LinearGradientBrush lgbDwnRect = new LinearGradientBrush(
                               rcDownRect,
                               m_clrFillStart,
                               m_clrFillEnd,
                               LinearGradientMode.Vertical
                               ))
                    {
                        g.FillRectangle(
                            lgbDwnRect,
                            rcDownRect
                            );
                    }

                    g.ResetClip();
                    break;
                }



                #endregion


                #region Draw back image
                DrawTitleBarBackImage(g, rcTitleBar, XTitleBarPath);
                #endregion

                DrawOuterTitleBarBorder(g, rcTitleBar, m_clrOuterTitleBarColor);
                DrawInnerTitleBarBorder(g, rcTitleBar, m_clrInnerTitleBarColor);
            }
            XTitleBarPath.Dispose();
        }