public GraphicsPath FindX3DBorderPrimitive(Rectangle rcBorder) { switch (m_eBorderType) { case GradualBorderType.Rounded: m_BorderShape = GradualFormHelper.RoundRect((RectangleF)rcBorder, m_lRadius, m_lRadius, 0, 0); break; case GradualBorderType.Inclinated: m_BorderShape = createInclinatedBorderPath(rcBorder); break; } return(m_BorderShape); }
/// <summary> /// Fills titlebar button. /// </summary> /// <param name="rcBtn"> Button bounding rectangle.</param> /// <param name="g"> Graphics object.</param> /// <param name="clrStart"> Color used to fill the button.</param> /// <param name="clrEnd"> Color used to fill the outer glow.</param> /// <param name="XBoxClip"> Path to perform clipping tasks.</param> private void FillButton(Rectangle rcBtn, Graphics g, Color clrStart, Color clrEnd, GraphicsPath XBoxClip) { switch (m_eFillMode) { case GradualButtonFillMode.UpperGlow: rcBtn.Height = 3; using (LinearGradientBrush lgb = new LinearGradientBrush( rcBtn, clrStart, clrEnd, LinearGradientMode.Vertical)) { g.FillRectangle( lgb, rcBtn ); } break; case GradualButtonFillMode.FullFill: // restrict drawing inside button box / rectangle: g.SetClip(XBoxClip); g.SetClip(rcBtn, CombineMode.Intersect); #region Fill button using (SolidBrush sb = new SolidBrush(clrStart)) { g.FillRectangle( sb, rcBtn ); } #endregion using (GradualAntiAlias xaa = new GradualAntiAlias(g)) { #region Fill shine using (GraphicsPath XBtnGlow = new GraphicsPath()) { XBtnGlow.AddEllipse(rcBtn.Left - 5, rcBtn.Bottom - rcBtn.Height / 2 + 3, rcBtn.Width + 11, rcBtn.Height + 11); using (PathGradientBrush pgb = new PathGradientBrush(XBtnGlow)) { pgb.CenterColor = Color.FromArgb(235, Color.White); pgb.SurroundColors = new Color[] { Color.FromArgb(0, clrEnd) }; pgb.SetSigmaBellShape(0.8f); g.FillPath( pgb, XBtnGlow ); } } #endregion #region Fill upper glow rcBtn.Height = rcBtn.Height / 2 - 2; using (LinearGradientBrush lgb = new LinearGradientBrush( rcBtn, Color.FromArgb(80, Color.White), Color.FromArgb(140, Color.White), LinearGradientMode.Vertical)) { using (GraphicsPath XGlowPath = GradualFormHelper.RoundRect((RectangleF)rcBtn, 0, 0, 4, 4)) { lgb.WrapMode = WrapMode.TileFlipXY; g.FillPath( lgb, XGlowPath ); } } #endregion } // reset clipping back: g.ResetClip(); break; } }
public void RenderTitleBarButtonsBox(Rectangle rcBox, Graphics g, int lSinglePosX, int lSinglePosY) { using (GradualAntiAlias xxx = new GradualAntiAlias(g)) { int lBtnWidth = 0; int lBtnHeight = 0; foreach (GradualTitleBarButton btn in m_xtbButtons) { if (btn.ButtonStyle == GradualTitleBarButton.GradualTitleBarButtonStyle.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 GradualButtonBoxFill.ColorMix: using (LinearGradientBrush lgb = new LinearGradientBrush( rcBox, m_ButtonBoxColors[0], m_ButtonBoxColors[4], LinearGradientMode.Vertical)) { lgb.InterpolationColors = GradualFormHelper.ColorMix ( m_ButtonBoxColors, false ); g.FillPath( lgb, XButtonBox ); } break; case GradualButtonBoxFill.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 (GradualTitleBarButton 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 (GradualTitleBarButton 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; } } } }
private void FillTitleBar(Graphics g, Rectangle rcTitleBar) { GraphicsPath GradualTitleBarPath = new GraphicsPath(); GradualTitleBarPath = BuildTitleBarShape(rcTitleBar); using (GradualAntiAlias xaa = new GradualAntiAlias(g)) { #region Fill titlebar switch (m_eTitleBarFill) { case GradualTitleBarFill.AdvancedRendering: using (LinearGradientBrush lgb = new LinearGradientBrush(rcTitleBar, m_TitleBarMix[0], m_TitleBarMix[4], LinearGradientMode.Vertical)) { lgb.InterpolationColors = GradualFormHelper.ColorMix(m_TitleBarMix, true); g.FillPath(lgb, GradualTitleBarPath); } #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(GradualTitleBarPath); g.FillPath(pgb, XGlow); g.ResetClip(); } } #endregion break; case GradualTitleBarFill.Texture: if (m_TitleBarTexture != null) { using (TextureBrush tb = new TextureBrush(m_TitleBarTexture)) { g.FillPath(tb, GradualTitleBarPath); } } break; case GradualTitleBarFill.LinearRendering: RectangleF rcLinearFill = GradualTitleBarPath.GetBounds(); g.SetClip(GradualTitleBarPath); using (LinearGradientBrush lgbLinearFill = new LinearGradientBrush( rcLinearFill, m_clrFillStart, m_clrFillEnd, LinearGradientMode.Vertical )) { g.FillRectangle( lgbLinearFill, rcLinearFill ); } g.ResetClip(); break; case GradualTitleBarFill.UpperGlow: RectangleF rcGlow = GradualTitleBarPath.GetBounds(); g.SetClip(GradualTitleBarPath); rcGlow.Height /= 2; using (LinearGradientBrush lgbUpperGlow = new LinearGradientBrush( rcGlow, m_clrUpperFillStart, m_clrUpperFillEnd, LinearGradientMode.Vertical )) { g.FillRectangle( lgbUpperGlow, rcGlow ); } g.ResetClip(); break; case GradualTitleBarFill.RectangleRendering: RectangleF rcDownRect = GradualTitleBarPath.GetBounds(); RectangleF rcUpRect = GradualTitleBarPath.GetBounds(); g.SetClip(GradualTitleBarPath); 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, GradualTitleBarPath); #endregion DrawOuterTitleBarBorder(g, rcTitleBar, m_clrOuterTitleBarColor); DrawInnerTitleBarBorder(g, rcTitleBar, m_clrInnerTitleBarColor); } GradualTitleBarPath.Dispose(); }
/// <summary> /// Draws inner & outer 3D borders. /// </summary> /// <param name="g"> Graphics object</param> /// <param name="XBorderPath"> Border path</param> /// <param name="rcBorder"> Border bounds</param> /// <param name="lCorner"> Radius of a rounded rectangle</param> /// <param name="bFlat"> Controls border type mode</param> private void DrawBorderLine(Graphics g, GraphicsPath XBorderPath, Rectangle rcBorder, int lCorner, bool bFlat, bool EntireClient) { int lC = lCorner; #region Draw outer border if (bFlat) { switch (m_eBorderType) { case GradualBorderType.Rectangular: XBorderPath = GradualFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, lC, lC); break; case GradualBorderType.Rounded: XBorderPath = GradualFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, 0, 0); break; case GradualBorderType.Inclinated: XBorderPath = createInclinatedBorderPath(rcBorder); break; } using (Pen pFlat = new Pen(m_clrFlatBorder)) { g.DrawPath(pFlat, XBorderPath); } } else { for (int o = 0; o < m_clrOuterBorder.Length; o++) { switch (m_eBorderType) { case GradualBorderType.Rectangular: XBorderPath = GradualFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, lC, lC); break; case GradualBorderType.Rounded: XBorderPath = GradualFormHelper.RoundRect((RectangleF)rcBorder, lC, lC, 0, 0); break; case GradualBorderType.Inclinated: XBorderPath = createInclinatedBorderPath(rcBorder); break; } Pen pen = new Pen(m_clrOuterBorder[o]); g.DrawPath( pen, XBorderPath ); DeflateRect(ref rcBorder); if (m_eBorderType != GradualBorderType.Rectangular) { lC--; } } #endregion #region Draw inner border //if (EntireClient) //{ // rcBorder.Y += m_lTitleBarHeight; // rcBorder.Height -= m_lTitleBarHeight; //} //for (int i = 0; i < m_clrInnerBorder.Length; i++) //{ // Pen penInner = new Pen(m_clrInnerBorder[i]); // g.DrawRectangle( // penInner, // rcBorder // ); // DeflateRect(ref rcBorder); //} } #endregion }