I have an object SOLIDBRUSH which accepts a color parameter like
SolidBrush(Color.Aqua) so.
So what i am trying to do now is to pass my combobox value like this
So what i am trying to do now is to pass my combobox value like this
SolidBrush(combobox1.selectedItem) To better understand my situation, let me post what the SolidBrush class contains, and what the Color class contains as well
SOLIDBRUSH CLASS
SOLIDBRUSH CLASS
- using System;
- 06 using WebSupergoo.ABCpdf10.Drawing;
- 07
- 08 namespace WebSupergoo.ABCpdf10.Drawing
- 09 {
- 10 public interface Brush
- 11 {
- 12 Color Color { get; set; }
- 13
- 14 }
- 15 }
- 16
- 17 #region SolidBrush
- 18 /// <summary>
- 19 /// Used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.
- 20 /// </summary>
- 21 public sealed class SolidBrush : Brush {
- 22 #region Declare variables
- 23 Color _color;
- 24
- 25 #endregion
- 26
- 27 #region Properties
- 28 /// <summary>
- 29 /// Gets or sets the color of this Brush object.
- 30 /// </summary>
- 31 public Color Color {
- 32 get { return _color; }
- 33 set { _color = value; }
- 34 }
- 35 #endregion
- 36
- 37 #region Constructors
- 38 /// <summary>
- 39 /// Initializes a new instance of the Brush class with
- 40 /// the specified Color property.
- 41 /// </summary>
- 42 /// <param name="color">The color of this System.Drawing.Pen object.</param>
- 43 public SolidBrush(Color color) {
- 44 _color = color;
- 45 }
- 46
- 47 #endregion
- 48
- 49 public override bool Equals(object obj) {
- 50 Brush b = obj as Brush;
- 51 if (b != null)
- 52 return b.Color.Equals(Color);
- 53 else
- 54 return false;
- 55 }
- 56
- 57 public override int GetHashCode() {
- 58 return base.GetHashCode ();
- 59 }
- 60 }
- 61 #endregion
- using System;
- 006
- 007 namespace WebSupergoo.ABCpdf10.Drawing {
- 008 #region Color
- 009 /// <summary>
- 010 /// A color in RGB, CMYK or Grayscale.
- 011 /// </summary>
- 012 public class Color {
- 013 #region Declare variables
- 014 internal double a = 1;
- 015 internal double r = 0;
- 016 internal double g = 0;
- 017 internal double b = 0;
- 018 internal double c = 0;
- 019 internal double m = 0;
- 020 internal double y = 0;
- 021 internal double k = 0;
- 022 internal double gray = 0;
- 023 #endregion
- 024
- 025 #region Properties
- 026 /// <summary>
- 027 /// Gets or sets the alpha component.
- 028 /// </summary>
- 029 public double A {
- 030 get { return a; }
- 031 set { a = value; }
- 032 }
- 033
- 034 /// <summary>
- 035 /// Gets or sets the red component.
- 036 /// </summary>
- 037 public double R {
- 038 get { return r; }
- 039 set { r = value; }
- 040 }
- 041
- 042 /// <summary>
- 043 /// Gets or sets the green component.
- 044 /// </summary>
- 045 public double G {
- 046 get { return g; }
- 047 set { g = value; }
- 048 }
- 049
- 050 /// <summary>
- 051 /// Gets or sets the blue component.
- 052 /// </summary>
- 053 public double B {
- 054 get { return b; }
- 055 set { b = value; }
- 056 }
- 057
- 058 /// <summary>
- 059 /// Gets or sets the cyan component.
- 060 /// </summary>
- 061 public double C {
- 062 get { return c; }
- 063 set { c = value; }
- 064 }
- 065
- 066 /// <summary>
- 067 /// Gets or sets the magenta component.
- 068 /// </summary>
- 069 public double M {
- 070 get { return m; }
- 071 set { m = value; }
- 072 }
- 073
- 074 /// <summary>
- 075 /// Gets or sets the yellow component.
- 076 /// </summary>
- 077 public double Y {
- 078 get { return y; }
- 079 set { y = value; }
- 080 }
- 081
- 082 /// <summary>
- 083 /// Gets or sets the black component.
- 084 /// </summary>
- 085 public double K {
- 086 get { return k; }
- 087 set { k = value; }
- 088 }
- 089
- 090 /// <summary>
- 091 /// Gets or sets the gray level.
- 092 /// </summary>
- 093 public double GrayScale {
- 094 get { return gray; }
- 095 set { gray = value; }
- 096 }
- 097 #endregion
- 098
- 099 public override bool Equals(object obj) {
- 100 Color c = obj as Color;
- 101 if (c != null)
- 102 return (A == c.A) && (R == c.R) && (G == c.G) && (B == c.B)/>/>;
- 103 else
- 104 return false;
- 105 }
- 106
- 107 public override int GetHashCode() {
- 108 return base.GetHashCode ();
- 109 }
- 110
- 111 #region Static methods
- 112 /// <summary>
- 113 /// Creates a Color from the specified 8-bit color values
- 114 /// (red, green, and blue). The alpha value is implicitly 255 (fully opaque).
- 115 /// </summary>
- 116 /// <param name="red">The red component value. Valid values are 0 through 255.</param>
- 117 /// <param name="green">The green component value. Valid values are 0 through 255.</param>
- 118 /// <param name="blue">The blue component value. Valid values are 0 through 255.</param>
- 119 /// <returns>The Color that this method creates.</returns>
- 120 public static Color FromArgb(int red, int green, int blue) {
- 121 return FromArgb(255, red, green, blue);
- 122 }
- 123
- 124
- 125
- 126 /// <summary>
- 127 /// Creates a Color from a 32-bit ARGB value.
- 128 /// </summary>
- 129 /// <param name="argb">A value specifying the 32-bit ARGB value.</param>
- 130 /// <returns>The Color that this method creates.</returns>
- 131 public static Color FromArgb(int argb) {
- 132 System.Drawing.Color clr = System.Drawing.Color.FromArgb(argb);
- 133 return FromArgb(clr.A, clr.R, clr.G, clr.B)/>/>;
- 134 }
- 135
- 136
- 137
- 138 /// <summary>
- 139 /// Creates a Color from the specified pre-defined color.
- 140 /// </summary>
- 141 /// <param name="color">An element of the System.Drawing.KnownColor enumeration.</param>
- 142 /// <returns>The Color that this method creates.</returns>
- 143 public static Color FromKnownColor(System.Drawing.KnownColor color) {
- 144 System.Drawing.Color sysColor = System.Drawing.Color.FromKnownColor(color);
- 145 return FromArgb(sysColor.A, sysColor.R, sysColor.G, sysColor.B)/>/>;
- 146 }
- 147
- 148 /// <summary>
- 149 /// Creates a Color from the specified System.Drawing.Color structure,
- 150 /// but with the new specified alpha value.
- 151 /// </summary>
- 152 /// <param name="alpha">The alpha value for the new System.Drawing.Color structure. Valid values are 0 through 255.</param>
- 153 /// <param name="baseColor">The System.Drawing.Color structure from which to create the new System.Drawing.Color structure.</param>
- 154 /// <returns>The Color that this method creates.</returns>
- 155 public static Color FromArgb(int alpha, System.Drawing.Color baseColor) {
- 156 return FromArgb(alpha, baseColor.R, baseColor.G, baseColor.B)/>/>;
- 157 }
- 158
- 159 /// <summary>
- 160 /// Creates a Color from the specified 8-bit RGB color values
- 161 /// (alpha, red, green, and blue).
- 162 /// </summary>
- 163 /// <param name="alpha">The alpha component value. Valid values are 0 through 255.</param>
- 164 /// <param name="red">The red component value. Valid values are 0 through 255.</param>
- 165 /// <param name="green">The green component value. Valid values are 0 through 255.</param>
- 166 /// <param name="blue">The blue component value. Valid values are 0 through 255.</param>
- 167 /// <returns>The Color that this method creates.</returns>
- 168 public static Color FromArgb(int alpha, int red, int green, int blue) {
- 169 Color clr = new Color();
- 170 clr.a = alpha / 255F;
- 171 clr.r = red / 255F;
- 172 clr.g = green / 255F;
- 173 clr.b = blue / 255F;
- 174 return clr;
- 175 }
- 176
- 177 /// <summary>
- 178 /// Creates a Color from the specified ARGB color values
- 179 /// (alpha, red, green, and blue).
- 180 /// </summary>
- 181 /// <param name="cyan">The alpha component. Valid values are 0 through 1.</param>
- 182 /// <param name="magenta">The red component. Valid values are 0 through 1.</param>
- 183 /// <param name="yellow">The green component. Valid values are 0 through 1.</param>
- 184 /// <param name="black">The blue component. Valid values are 0 through 1.</param>
- 185 /// <returns>The Color that this method creates.</returns>
- 186 public static Color FromArgb(double alpha, double red, double green, double blue) {
- 187 Color clr = new Color();
- 188 clr.a = alpha;
- 189 clr.r = red;
- 190 clr.g = green;
- 191 clr.b = blue;
- 192 return clr;
- 193 }
- 194
- 195 /// <summary>
- 196 /// Creates a Color from the specified CMYK color values
- 197 /// (cyan, magenta, yellow, and black).
- 198 /// </summary>
- 199 /// <param name="cyan">The cyan component. Valid values are 0 through 1.</param>
- 200 /// <param name="magenta">The magenta component. Valid values are 0 through 1.</param>
- 201 /// <param name="yellow">The yellow component. Valid values are 0 through 1.</param>
- 202 /// <param name="black">The black component. Valid values are 0 through 1.</param>
- 203 /// <returns>The Color that this method creates.</returns>
- 204 public static Color FromCmyk(double cyan, double magenta, double yellow, double black) {
- 205 Color clr = new Color();
- 206 clr.c = cyan;
- 207 clr.m = magenta;
- 208 clr.y = yellow;
- 209 clr.k = black;
- 210 return clr;
- 211 }
- 212
- 213 /// <summary>
- 214 /// Creates a Color from the specified gray level.
- 215 /// </summary>
- 216 /// <param name="gray">The gray component. Valid values are 0 through 1.</param>
- 217 /// <returns>The Color that this method creates.</returns>
- 218 public static Color FromCmyk(double gray) {
- 219 Color clr = new Color();
- 220 clr.gray = gray;
- 221 return clr;
- 222 }
- 223
- 224 /// <summary>
- 225 /// Gets a system defined color
- 226 /// </summary>
- 227 public static Color AliceBlue { get { return FromKnownColor(System.Drawing.KnownColor.AliceBlue); } }
- 228 public static Color Yellow { get { return FromKnownColor(System.Drawing.KnownColor.Yellow); } }
- 229
- 230 LIST of colors goes on..
Thanks
Nigel FernandesPosted Jun 21, 2016, 11:31 PM
Derstine BuyaganPosted Jun 21, 2016, 11:14 PM
SolidBrush(Color.Aqua)Nigel FernandesPosted Jun 21, 2016, 10:48 PM