private static void OnPaint_CheckBox(System.Windows.Forms.CheckBox pCheckBox, System.Windows.Forms.PaintEventArgs e) { if (pCheckBox.Tag == null || (pCheckBox.Tag != null && !pCheckBox.Tag.Equals("SemRenderizacao"))) { using (GradualAntiAlias xaa = new GradualAntiAlias(e.Graphics)) { System.Drawing.Rectangle clientRect = new System.Drawing.Rectangle(pCheckBox.ClientRectangle.X, pCheckBox.ClientRectangle.Y + (pCheckBox.Height - 16) / 2, 16, 16); e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; e.Graphics.FillRectangle(new System.Drawing.SolidBrush(StyleSettings.Panel_BackGround_Color_Start), pCheckBox.ClientRectangle); e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(clientRect, StyleSettings.CheckBox_BackGround_Color_Start, StyleSettings.CheckBox_BackGround_Color_Finish, 90F), clientRect.X + 2, clientRect.Y + 2, 12, 12); e.Graphics.DrawRectangle(StyleSettings.Pen_Borda_TextBox, clientRect.X + 2, clientRect.Y + 2, 12, 12); if (pCheckBox.Checked) { e.Graphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.White), clientRect.X + 4, clientRect.Y + 4, clientRect.Width - 8, clientRect.Height - 8); } //clientRect = new System.Drawing.Rectangle(clientRect.X + 20, clientRect.Y + 3, pCheckBox.ClientRectangle.Width - 20, clientRect.Height); clientRect = new System.Drawing.Rectangle(clientRect.X - 15, clientRect.Y + 1, pCheckBox.ClientRectangle.Width - 15, clientRect.Height); e.Graphics.DrawString(pCheckBox.Text, pCheckBox.Font, StyleSettings.Brush_Txt_Label, clientRect, StyleSettings.FormatoDaFonte_Botao); } } }
/// <summary> /// Main rendering method. /// </summary> /// <param name="rcBorder"> Border bounds</param> /// <param name="g"> Graphics object</param> public void Render(Rectangle rcBorder, Graphics g, bool EntireClient) { GraphicsPath XBorderPath = new GraphicsPath(); switch (m_eBorderStyle) { case GradualBorderStyle.X3D: switch (m_eBorderType) { case GradualBorderType.Rectangular: using (GradualAntiAlias xaa = new GradualAntiAlias(g)) { DrawBorderLine(g, XBorderPath, rcBorder, 0, false, EntireClient); } break; case GradualBorderType.Rounded: DrawBorderLine(g, XBorderPath, rcBorder, m_lRadius, false, EntireClient); break; case GradualBorderType.Inclinated: DrawBorderLine(g, XBorderPath, rcBorder, 0, false, EntireClient); break; } break; case GradualBorderStyle.Flat: switch (m_eBorderType) { case GradualBorderType.Rectangular: using (GradualAntiAlias xaa = new GradualAntiAlias(g)) { DrawBorderLine(g, XBorderPath, rcBorder, 0, true, EntireClient); } break; case GradualBorderType.Rounded: { DrawBorderLine(g, XBorderPath, rcBorder, m_lRadius, true, EntireClient); } break; case GradualBorderType.Inclinated: { DrawBorderLine(g, XBorderPath, rcBorder, 0, false, EntireClient); } break; } break; } }
private void DrawStatusGlow( Rectangle rect, Graphics g, Color clrGlowColor ) { Rectangle rcGlow = rect; using (LinearGradientBrush lgbGlow = new LinearGradientBrush( rcGlow, Color.FromArgb(30, clrGlowColor), Color.FromArgb(150, clrGlowColor), LinearGradientMode.Vertical)) { if (m_bEllipticalGlow) { g.SetClip(rect); using (GradualAntiAlias xaa = new GradualAntiAlias(g)) { using (GraphicsPath XEllipseGlow = new GraphicsPath()) { XEllipseGlow.AddEllipse( rect.Left - 5, rect.Top - rect.Height / 2, rect.Width + 10, rect.Height); g.FillPath( lgbGlow, XEllipseGlow ); } } g.ResetClip(); } else { rcGlow.Height = 5; g.FillRectangle( lgbGlow, rcGlow ); } } }
private static void OnPaint_Label(System.Windows.Forms.Label pLabel, System.Windows.Forms.PaintEventArgs e) { if (pLabel.Tag == null || (pLabel.Tag != null && !pLabel.Tag.Equals("SemRenderizacao"))) { using (GradualAntiAlias xaa = new GradualAntiAlias(e.Graphics)) { using (System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(pLabel.ClientRectangle, StyleSettings.Label_BackGround_Color_Start, StyleSettings.Label_BackGround_Color_Finish, 45F)) { e.Graphics.FillRectangle(brush, pLabel.ClientRectangle); e.Graphics.DrawRectangle( new System.Drawing.Pen( new System.Drawing.SolidBrush(StyleSettings.Panel_BackGround_Color_Start), 0.5F), e.ClipRectangle); Int32 numAlign = (Int32)Math.Log((Double)pLabel.TextAlign, 2); System.Drawing.StringFormat formatoLabel = new System.Drawing.StringFormat() { Alignment = (System.Drawing.StringAlignment)(numAlign % 4), LineAlignment = (System.Drawing.StringAlignment)(numAlign / 4) }; if (pLabel.Image != null) { if (string.IsNullOrEmpty(pLabel.Text)) { e.Graphics.DrawImage(pLabel.Image, new System.Drawing.Rectangle(pLabel.ClientRectangle.X + StyleSettings.DeslocaImagem_Label, pLabel.ClientRectangle.Y + StyleSettings.DeslocaImagem_Label, pLabel.Image.Width, pLabel.Image.Height)); } else { //e.Graphics.DrawImage(pLabel.Image, new System.Drawing.Rectangle(pLabel.ClientRectangle.X + StyleSettings.DeslocaImagem_Label, pLabel.ClientRectangle.Y + StyleSettings.DeslocaImagem_Label, pLabel.Image.Width, pLabel.Image.Height)); e.Graphics.DrawString(pLabel.Text, pLabel.Font, StyleSettings.Brush_Txt_Botao, pLabel.ClientRectangle, formatoLabel); } } else { e.Graphics.DrawString(pLabel.Text, pLabel.Font, StyleSettings.Brush_Txt_Label, pLabel.ClientRectangle, formatoLabel); } } } } }
private static void OnPaint_Panel(System.Windows.Forms.Panel pPanel, System.Windows.Forms.PaintEventArgs e) { if (pPanel.ClientRectangle.X > 0 && pPanel.ClientRectangle.Y > 0) { if (pPanel.Tag == null || (pPanel.Tag != null && pPanel.Tag != "SemRenderizacao")) { using (GradualAntiAlias xaa = new GradualAntiAlias(e.Graphics)) { using (System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(pPanel.ClientRectangle, StyleSettings.Panel_BackGround_Color_Start, StyleSettings.Panel_BackGround_Color_Finish, 90F)) { e.Graphics.FillRectangle(brush, pPanel.ClientRectangle); e.Graphics.DrawRectangle( new System.Drawing.Pen( new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(42, 42, 42)), 0.5F), e.ClipRectangle); } } } } }
private static void OnPaint_Button(System.Windows.Forms.Button pButton, System.Windows.Forms.PaintEventArgs e) { if (pButton.Tag == null || (pButton.Tag != null && !pButton.Tag.Equals("SemRenderizacao"))) { using (GradualAntiAlias xaa = new GradualAntiAlias(e.Graphics)) { using (System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(pButton.ClientRectangle, StyleSettings.Button_BackGround_Color_Start, StyleSettings.Button_BackGround_Color_Finish, 45F)) { e.Graphics.FillRectangle(brush, pButton.ClientRectangle); } } e.Graphics.DrawRectangle(StyleSettings.Pen_Borda_Botao , pButton.ClientRectangle.X , pButton.ClientRectangle.Y , pButton.ClientRectangle.Width - 1 , pButton.ClientRectangle.Height - 1); e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; if (pButton.Image != null) { if (string.IsNullOrEmpty(pButton.Text)) { e.Graphics.DrawImage(pButton.Image, new System.Drawing.Rectangle(pButton.ClientRectangle.X + StyleSettings.DeslocaImagem_Botao, pButton.ClientRectangle.Y + StyleSettings.DeslocaImagem_Botao, pButton.Image.Width, pButton.Image.Height)); } else { e.Graphics.DrawImage(pButton.Image, new System.Drawing.Rectangle(pButton.ClientRectangle.X + StyleSettings.DeslocaImagem_Botao, pButton.ClientRectangle.Y + StyleSettings.DeslocaImagem_Botao, pButton.Image.Width, pButton.Image.Height)); e.Graphics.DrawString(pButton.Text, pButton.Font, StyleSettings.Brush_Txt_Botao, pButton.ClientRectangle, StyleSettings.FormatoDaFonte_Botao); } } else { e.Graphics.DrawString(pButton.Text, pButton.Font, StyleSettings.Brush_Txt_Botao, pButton.ClientRectangle, StyleSettings.FormatoDaFonte_Botao); } } }
public void RenderHolderButtons( int x, int y, Graphics g ) { int lX = x; Rectangle rcIcon = new Rectangle(); RectangleF rcImage = new RectangleF(); RectangleF rcFrame = new RectangleF(); foreach (GradualHolderButton xbtn in m_xhBtn) { if (xbtn.ButtonImage != null) { xbtn.Left = lX; xbtn.Top = y + 1; rcIcon = new Rectangle( lX, y + 1, xbtn.ButtonImage.Size.Width, xbtn.ButtonImage.Size.Height ); if (xbtn.Hot) { using (GradualAntiAlias xaa = new GradualAntiAlias(g)) { using (GraphicsPath XHolderBtnPath = BuildHolderButtonFrame(rcIcon, 100, 40)) { using (LinearGradientBrush lgb = new LinearGradientBrush( XHolderBtnPath.GetBounds(), Color.FromArgb(xbtn.FrameAlpha, xbtn.FrameStartColor), Color.FromArgb(xbtn.FrameAlpha, xbtn.FrameEndColor), LinearGradientMode.Vertical )) { g.FillPath( lgb, XHolderBtnPath ); } rcFrame = XHolderBtnPath.GetBounds(); } int lFrameImageWidth = 0; if (xbtn.FrameBackImage != null) { // draw frame image: rcImage = new RectangleF( rcFrame.Right - xbtn.FrameBackImage.Width, rcFrame.Bottom - xbtn.FrameBackImage.Height, xbtn.FrameBackImage.Width, xbtn.FrameBackImage.Height ); g.DrawImage(xbtn.FrameBackImage, rcImage); lFrameImageWidth = xbtn.FrameBackImage.Height; } // draw caption / description: g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; g.DrawString( xbtn.GradualHolderButtonCaption, xbtn.GradualHolderButtonCaptionFont, new SolidBrush(xbtn.GradualHolderButtonCaptionColor), rcFrame.Left + 2, rcIcon.Bottom + 4 ); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Near; sf.Trimming = StringTrimming.EllipsisCharacter; sf.FormatFlags = StringFormatFlags.LineLimit; float fCaptionWidth = g.MeasureString(xbtn.GradualHolderButtonCaption, xbtn.GradualHolderButtonCaptionFont).Height; RectangleF rcDescription = new RectangleF( rcFrame.Left + 2, rcIcon.Bottom + fCaptionWidth, rcFrame.Width, rcFrame.Height - lFrameImageWidth); g.DrawString( xbtn.GradualHolderButtonDescription, xbtn.GradualHolderButtonDescriptionFont, new SolidBrush(xbtn.GradualHolderButtonDescriptionColor), rcDescription, sf); } } // draw button: g.DrawImage( xbtn.ButtonImage, rcIcon ); xbtn.ButtonRectangle = rcIcon; // update position: lX += rcIcon.Width + 2; } } }
/// <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(); }