public SolidBrush(Color_ color) { this.color = color; Status status = GDIPlus.GdipCreateSolidFill(color.ToArgb(), out nativeObject); GDIPlus.CheckStatus(status); }
public void SetColorKey(Color_ colorLow, Color_ colorHigh, ColorAdjustType type) { Status status = GDIPlus.GdipSetImageAttributesColorKeys(nativeImageAttr, type, true, colorLow.ToArgb(), colorHigh.ToArgb()); GDIPlus.CheckStatus(status); }
public static Color_ Light(Color_ baseColor, float percOfLightLight) { if (baseColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb()) { int r_sub, g_sub, b_sub; Color_ color; if (percOfLightLight <= 0f) { return(ThemeEngine.Current.ColorControlLight); } if (percOfLightLight == 1.0f) { return(ThemeEngine.Current.ColorControlLightLight); } r_sub = ThemeEngine.Current.ColorControlLightLight.R - ThemeEngine.Current.ColorControlLight.R; g_sub = ThemeEngine.Current.ColorControlLightLight.G - ThemeEngine.Current.ColorControlLight.G; b_sub = ThemeEngine.Current.ColorControlLightLight.B - ThemeEngine.Current.ColorControlLight.B; color = Color_.FromArgb(ThemeEngine.Current.ColorControlLight.A, (int)(ThemeEngine.Current.ColorControlLight.R + (r_sub * percOfLightLight)), (int)(ThemeEngine.Current.ColorControlLight.G + (g_sub * percOfLightLight)), (int)(ThemeEngine.Current.ColorControlLight.B + (b_sub * percOfLightLight))); return(color); } int H, I, S; ControlPaint.Color2HBS(baseColor, out H, out I, out S); int NewIntensity = Math.Min(255, I + (int)((255 - I) * 0.5f * percOfLightLight)); return(ControlPaint.HBS2Color(H, NewIntensity, S)); }
public LinearGradientBrush(RectangleF_ rect, Color_ color1, Color_ color2, float angle, bool isAngleScaleable) { Status status = GDIPlus.GdipCreateLineBrushFromRectWithAngle(ref rect, color1.ToArgb(), color2.ToArgb(), angle, isAngleScaleable, WrapMode.Tile, out nativeObject); GDIPlus.CheckStatus(status); rectangle = rect; }
public LinearGradientBrush(RectangleF_ rect, Color_ color1, Color_ color2, LinearGradientMode linearGradientMode) { Status status = GDIPlus.GdipCreateLineBrushFromRect(ref rect, color1.ToArgb(), color2.ToArgb(), linearGradientMode, WrapMode.Tile, out nativeObject); GDIPlus.CheckStatus(status); rectangle = rect; }
public virtual void Draw(Graphics g, Rectangle_ bounds, ButtonThemeState state, Color_ backColor, Color_ foreColor) { bool is_themecolor = backColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb() || backColor == Color_.Empty ? true : false; CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor(backColor); Pen pen; switch (state) { case ButtonThemeState.Normal: case ButtonThemeState.Entered: case ButtonThemeState.Disabled: pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen(cpcolor.LightLight); g.DrawLine(pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2); g.DrawLine(pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y); pen = is_themecolor ? SystemPens.Control : ResPool.GetPen(backColor); g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3); g.DrawLine(pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1); pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen(cpcolor.Dark); g.DrawLine(pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2); g.DrawLine(pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3); pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen(cpcolor.DarkDark); g.DrawLine(pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1); g.DrawLine(pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2); break; case ButtonThemeState.Pressed: g.DrawRectangle(ResPool.GetPen(foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); bounds.Inflate(-1, -1); pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen(cpcolor.Dark); g.DrawRectangle(pen, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); break; case ButtonThemeState.Default: g.DrawRectangle(ResPool.GetPen(foreColor), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1); bounds.Inflate(-1, -1); pen = is_themecolor ? SystemPens.ControlLightLight : ResPool.GetPen(cpcolor.LightLight); g.DrawLine(pen, bounds.X, bounds.Y, bounds.X, bounds.Bottom - 2); g.DrawLine(pen, bounds.X + 1, bounds.Y, bounds.Right - 2, bounds.Y); pen = is_themecolor ? SystemPens.Control : ResPool.GetPen(backColor); g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Bottom - 3); g.DrawLine(pen, bounds.X + 2, bounds.Y + 1, bounds.Right - 3, bounds.Y + 1); pen = is_themecolor ? SystemPens.ControlDark : ResPool.GetPen(cpcolor.Dark); g.DrawLine(pen, bounds.X + 1, bounds.Bottom - 2, bounds.Right - 2, bounds.Bottom - 2); g.DrawLine(pen, bounds.Right - 2, bounds.Y + 1, bounds.Right - 2, bounds.Bottom - 3); pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetPen(cpcolor.DarkDark); g.DrawLine(pen, bounds.X, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1); g.DrawLine(pen, bounds.Right - 1, bounds.Y, bounds.Right - 1, bounds.Bottom - 2); break; } }
public LinearGradientBrush(PointF_ point1, PointF_ point2, Color_ color1, Color_ color2) { Status status = GDIPlus.GdipCreateLineBrush(ref point1, ref point2, color1.ToArgb(), color2.ToArgb(), WrapMode.Tile, out nativeObject); GDIPlus.CheckStatus(status); status = GDIPlus.GdipGetLineRect(nativeObject, out rectangle); GDIPlus.CheckStatus(status); }
public Pen GetPen(Color_ color) { int hash = color.ToArgb(); lock (pens) { Pen res = pens [hash] as Pen; if (res != null) { return(res); } Pen pen = new Pen(color); pens.Add(hash, pen); return(pen); } }
public SolidBrush GetSolidBrush(Color_ color) { int hash = color.ToArgb(); lock (solidbrushes) { SolidBrush res = solidbrushes [hash] as SolidBrush; if (res != null) { return(res); } SolidBrush brush = new SolidBrush(color); solidbrushes.Add(hash, brush); return(brush); } }
private void SetSystemColors(KnownColor kc, Color_ value) { if (update == null) { Type known_colors = Type.GetType("System.Drawing.KnownColors, " + Consts.AssemblySystem_Drawing); if (known_colors != null) { update = known_colors.GetMethod("Update", BindingFlags.Static | BindingFlags.Public); } } if (update != null) { update.Invoke(null, new object [2] { (int)kc, value.ToArgb() }); } }
// FIXME: Linear scan public static Color_ FindColorMatch(Color_ c) { uint argb = (uint)c.ToArgb(); // 1-based const int first_real_color_index = (int)KnownColor.AliceBlue; const int last_real_color_index = (int)KnownColor.YellowGreen; for (int i = first_real_color_index - 1; i < last_real_color_index; i++) { if (argb == KnownColors.ArgbValues [i]) { return(KnownColors.FromKnownColor((KnownColor)i)); } } return(Color_.Empty); }
public static Color_ Dark(Color_ baseColor, float percOfDarkDark) { if (baseColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb()) { int r_sub, g_sub, b_sub; Color_ color; if (percOfDarkDark <= 0f) { return(ThemeEngine.Current.ColorControlDark); } if (percOfDarkDark == 1.0f) { return(ThemeEngine.Current.ColorControlDarkDark); } r_sub = ThemeEngine.Current.ColorControlDarkDark.R - ThemeEngine.Current.ColorControlDark.R; g_sub = ThemeEngine.Current.ColorControlDarkDark.G - ThemeEngine.Current.ColorControlDark.G; b_sub = ThemeEngine.Current.ColorControlDarkDark.B - ThemeEngine.Current.ColorControlDark.B; color = Color_.FromArgb(ThemeEngine.Current.ColorControlDark.A, (int)(ThemeEngine.Current.ColorControlDark.R + (r_sub * percOfDarkDark)), (int)(ThemeEngine.Current.ColorControlDark.G + (g_sub * percOfDarkDark)), (int)(ThemeEngine.Current.ColorControlDark.B + (b_sub * percOfDarkDark))); return(color); } int H, I, S; ControlPaint.Color2HBS(baseColor, out H, out I, out S); int PreIntensity = Math.Max(0, I - (int)(I * 0.333f)); int NewIntensity = Math.Max(0, PreIntensity - (int)(PreIntensity * percOfDarkDark)); return(ControlPaint.HBS2Color(H, NewIntensity, S)); }
public void SetWrapMode(WrapMode mode, Color_ color, bool clamp) { Status status = GDIPlus.GdipSetImageAttributesWrapMode(nativeImageAttr, mode, color.ToArgb(), clamp); GDIPlus.CheckStatus(status); }
public HatchBrush(HatchStyle hatchStyle, Color_ foreColor, Color_ backColor) { Status status = GDIPlus.GdipCreateHatchBrush(hatchStyle, foreColor.ToArgb(), backColor.ToArgb(), out nativeObject); GDIPlus.CheckStatus(status); }
public virtual void DrawFlat(Graphics g, Rectangle_ bounds, ButtonThemeState state, Color_ backColor, Color_ foreColor, FlatButtonAppearance appearance) { bool is_themecolor = backColor.ToArgb() == ThemeEngine.Current.ColorControl.ToArgb() || backColor == Color_.Empty ? true : false; CPColor cpcolor = is_themecolor ? CPColor.Empty : ResPool.GetCPColor(backColor); Pen pen; switch (state) { case ButtonThemeState.Normal: case ButtonThemeState.Disabled: // This will just use the BackColor break; case ButtonThemeState.Entered: case ButtonThemeState.Default | ButtonThemeState.Entered: if (appearance.MouseOverBackColor != Color_.Empty) { g.FillRectangle(ResPool.GetSolidBrush(appearance.MouseOverBackColor), bounds); } else { g.FillRectangle(ResPool.GetSolidBrush(ChangeIntensity(backColor, .9F)), bounds); } break; case ButtonThemeState.Pressed: if (appearance.MouseDownBackColor != Color_.Empty) { g.FillRectangle(ResPool.GetSolidBrush(appearance.MouseDownBackColor), bounds); } else { g.FillRectangle(ResPool.GetSolidBrush(ChangeIntensity(backColor, .95F)), bounds); } break; case ButtonThemeState.Default: if (appearance.CheckedBackColor != Color_.Empty) { g.FillRectangle(ResPool.GetSolidBrush(appearance.CheckedBackColor), bounds); } break; } if (appearance.BorderColor == Color_.Empty) { pen = is_themecolor ? SystemPens.ControlDarkDark : ResPool.GetSizedPen(cpcolor.DarkDark, appearance.BorderSize); } else { pen = ResPool.GetSizedPen(appearance.BorderColor, appearance.BorderSize); } bounds.Width -= 1; bounds.Height -= 1; if (appearance.BorderSize > 0) { g.DrawRectangle(pen, bounds); } }