/// <summary> /// Get color by theme style. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <param name="darkRGB">RGB value for the Dark style.</param> /// <param name="restRGB">RGB value for the rest style.</param> /// <returns>Color instance.</returns> private static Color GetColorByThemeStyle(ModernThemeStyle themeStyle, int darkRGB, int restRGB) { if (themeStyle == ModernThemeStyle.Dark) { return(Color.FromArgb(darkRGB, darkRGB, darkRGB)); } return(Color.FromArgb(restRGB, restRGB, restRGB)); }
/// <summary> /// ModernToolTipDraw method. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">A System.EventArgs that contains the event data.</param> private void ModernToolTipDraw(object sender, DrawToolTipEventArgs e) { ModernThemeStyle displayTheme = this.ThemeStyle == ModernThemeStyle.Light ? ModernThemeStyle.Dark : ModernThemeStyle.Light; Color backColor = ModernPaint.BackColor.Form(displayTheme); Color borderColor = ModernPaint.BorderColor.Button.Normal(displayTheme); Color foreColor = ModernPaint.ForeColor.Label.Normal(displayTheme); using (SolidBrush brush = new SolidBrush(backColor)) { e.Graphics.FillRectangle(brush, e.Bounds); } using (Pen pen = new Pen(borderColor)) { e.Graphics.DrawRectangle(pen, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1)); } Font font = ModernFonts.GetDefaultFont(13f, ModernFontWeight.Regular); TextRenderer.DrawText(e.Graphics, e.ToolTipText, font, e.Bounds, foreColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); }
/// <summary> /// Get disabled color. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <returns>Color instance.</returns> public static Color Disabled(ModernThemeStyle themeStyle) { return(GetColorByThemeStyle(themeStyle, 209, 209)); }
/// <summary> /// Get press color. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <returns>Color instance.</returns> public static Color Press(ModernThemeStyle themeStyle) { return(GetColorByThemeStyle(themeStyle, 255, 255)); }
/// <summary> /// Get hover color. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <returns>Color instance.</returns> public static Color Hover(ModernThemeStyle themeStyle) { return(GetColorByThemeStyle(themeStyle, 17, 255)); }
/// <summary> /// Get normal color. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <returns>Color instance.</returns> public static Color Normal(ModernThemeStyle themeStyle) { return(GetColorByThemeStyle(themeStyle, 204, 0)); }
/// <summary> /// Get title color. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <returns>Color instance.</returns> public static Color Title(ModernThemeStyle themeStyle) { return(GetColorByThemeStyle(themeStyle, 255, 0)); }
/// <summary> /// Get form color. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <returns>Color instance.</returns> public static Color Form(ModernThemeStyle themeStyle) { return(GetColorByThemeStyle(themeStyle, 68, 204)); }
/// <summary> /// Initializes a new instance of the <see cref="ContextColors"/> class. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <param name="colorStyle">Modern color style.</param> public ContextColors(ModernThemeStyle themeStyle, ModernColorStyle colorStyle) { this._modernThemeStyle = themeStyle; this._modernColorStyle = colorStyle; }
/// <summary> /// Initializes a new instance of the <see cref="ModernToolStripRenderer"/> class. /// </summary> /// <param name="themeStyle">Modern theme style.</param> /// <param name="colorStyle">Modern color style.</param> public ModernToolStripRenderer(ModernThemeStyle themeStyle, ModernColorStyle colorStyle) : base(new ContextColors(themeStyle, colorStyle)) { }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { Color backColor; Color foreColor; ModernThemeStyle modernThemeStyle = this.ThemeStyle; if (this.UseCustomBackColor) { backColor = this.BackColor; } else { if (this.Parent != null) { if (this.Parent is IModernForm) { modernThemeStyle = ((IModernForm)Parent).ThemeStyle; backColor = ModernPaint.BackColor.Form(modernThemeStyle); } else if (this.Parent is IModernControl) { backColor = ModernPaint.GetStyleColor(this.ColorStyle); } else { backColor = this.Parent.BackColor; } } else { backColor = ModernPaint.BackColor.Form(modernThemeStyle); } } if (this._isHovered && !this._isPressed && this.Enabled) { foreColor = this.UseCustomForeColor ? this.ForeColor : ModernPaint.ForeColor.Button.Normal(modernThemeStyle); backColor = this.UseCustomBackColor ? this.BackColor : ModernPaint.BackColor.Button.Normal(modernThemeStyle); } else if (this._isHovered && this._isPressed && this.Enabled) { foreColor = this.UseCustomForeColor ? this.ForeColor : ModernPaint.ForeColor.Button.Press(modernThemeStyle); backColor = this.UseCustomBackColor ? this.BackColor : ModernPaint.GetStyleColor(this.ColorStyle); } else if (!this.Enabled) { foreColor = this.UseCustomForeColor ? this.ForeColor : ModernPaint.ForeColor.Button.Disabled(modernThemeStyle); backColor = this.UseCustomBackColor ? this.BackColor : ModernPaint.BackColor.Button.Disabled(modernThemeStyle); } else { foreColor = this.UseCustomForeColor ? this.ForeColor : ModernPaint.ForeColor.Button.Normal(modernThemeStyle); } e.Graphics.Clear(backColor); using (Font buttonFont = new Font("Webdings", 9.25f)) { TextRenderer.DrawText(e.Graphics, this.Text, buttonFont, this.ClientRectangle, foreColor, backColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); } }