Вопрос о библиотеке websupergoo
Привет, мне трудно присвоить значение цвета рисунку. То, что я пытаюсь сделать, это выбрать из значения comboBox, которое имеет значения цвета.
foreach (System.Reflection.PropertyInfo prop in typeof(WebSupergoo.ABCpdf10.Drawing.Color).GetProperties()) { if (prop.PropertyType.FullName == "WebSupergoo.ABCpdf10.Drawing.Color") colorComboBox.Items.Add(prop.Name); }
Поскольку это сторонний элемент управления, я попытаюсь вставить другие классы, поскольку класс color не является прямым производным от system.drawing.color.
Вот класс solidbrush
// =========================================================================== // ©2013 WebSupergoo. All rights reserved. // =========================================================================== using System; using WebSupergoo.ABCpdf10.Drawing; namespace WebSupergoo.ABCpdf10.Drawing { public interface Brush { Color Color { get; set; } } } #region SolidBrush /// <summary> /// Used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths. /// </summary> public sealed class SolidBrush : Brush { #region Declare variables Color _color; #endregion #region Properties /// <summary> /// Gets or sets the color of this Brush object. /// </summary> public Color Color { get { return _color; } set { _color = value; } } #endregion #region Constructors /// <summary> /// Initializes a new instance of the Brush class with /// the specified Color property. /// </summary> /// <param name="color">The color of this System.Drawing.Pen object.</param> public SolidBrush(Color color) { _color = color; } #endregion public override bool Equals(object obj) { Brush b = obj as Brush; if (b != null) return b.Color.Equals(Color); else return false; } public override int GetHashCode() { return base.GetHashCode (); } } #endregion
а вот и сам цветовой класс.
// =========================================================================== // ©2013 WebSupergoo. All rights reserved. // =========================================================================== using System; namespace WebSupergoo.ABCpdf10.Drawing { #region Color /// <summary> /// A color in RGB, CMYK or Grayscale. /// </summary> public class Color { #region Declare variables internal double a = 1; internal double r = 0; internal double g = 0; internal double b = 0; internal double c = 0; internal double m = 0; internal double y = 0; internal double k = 0; internal double gray = 0; #endregion #region Properties /// <summary> /// Gets or sets the alpha component. /// </summary> public double A { get { return a; } set { a = value; } } /// <summary> /// Gets or sets the red component. /// </summary> public double R { get { return r; } set { r = value; } } /// <summary> /// Gets or sets the green component. /// </summary> public double G { get { return g; } set { g = value; } } /// <summary> /// Gets or sets the blue component. /// </summary> public double B { get { return b; } set { b = value; } } /// <summary> /// Gets or sets the cyan component. /// </summary> public double C { get { return c; } set { c = value; } } /// <summary> /// Gets or sets the magenta component. /// </summary> public double M { get { return m; } set { m = value; } } /// <summary> /// Gets or sets the yellow component. /// </summary> public double Y { get { return y; } set { y = value; } } /// <summary> /// Gets or sets the black component. /// </summary> public double K { get { return k; } set { k = value; } } /// <summary> /// Gets or sets the gray level. /// </summary> public double GrayScale { get { return gray; } set { gray = value; } } #endregion public override bool Equals(object obj) { Color c = obj as Color; if (c != null) return (A == c.A) && (R == c.R) && (G == c.G) && (B == c.B); else return false; } public override int GetHashCode() { return base.GetHashCode (); } #region Static methods /// <summary> /// Creates a Color from the specified 8-bit color values /// (red, green, and blue). The alpha value is implicitly 255 (fully opaque). /// </summary> /// <param name="red">The red component value. Valid values are 0 through 255.</param> /// <param name="green">The green component value. Valid values are 0 through 255.</param> /// <param name="blue">The blue component value. Valid values are 0 through 255.</param> /// <returns>The Color that this method creates.</returns> public static Color FromArgb(int red, int green, int blue) { return FromArgb(255, red, green, blue); } /// <summary> /// Creates a Color from a 32-bit ARGB value. /// </summary> /// <param name="argb">A value specifying the 32-bit ARGB value.</param> /// <returns>The Color that this method creates.</returns> public static Color FromArgb(int argb) { System.Drawing.Color clr = System.Drawing.Color.FromArgb(argb); return FromArgb(clr.A, clr.R, clr.G, clr.B); } /// <summary> /// Creates a Color from the specified pre-defined color. /// </summary> /// <param name="color">An element of the System.Drawing.KnownColor enumeration.</param> /// <returns>The Color that this method creates.</returns> public static Color FromKnownColor(System.Drawing.KnownColor color) { System.Drawing.Color sysColor = System.Drawing.Color.FromKnownColor(color); return FromArgb(sysColor.A, sysColor.R, sysColor.G, sysColor.B); } /// <summary> /// Creates a Color from the specified System.Drawing.Color structure, /// but with the new specified alpha value. /// </summary> /// <param name="alpha">The alpha value for the new System.Drawing.Color structure. Valid values are 0 through 255.</param> /// <param name="baseColor">The System.Drawing.Color structure from which to create the new System.Drawing.Color structure.</param> /// <returns>The Color that this method creates.</returns> public static Color FromArgb(int alpha, System.Drawing.Color baseColor) { return FromArgb(alpha, baseColor.R, baseColor.G, baseColor.B); } /// <summary> /// Creates a Color from the specified 8-bit RGB color values /// (alpha, red, green, and blue). /// </summary> /// <param name="alpha">The alpha component value. Valid values are 0 through 255.</param> /// <param name="red">The red component value. Valid values are 0 through 255.</param> /// <param name="green">The green component value. Valid values are 0 through 255.</param> /// <param name="blue">The blue component value. Valid values are 0 through 255.</param> /// <returns>The Color that this method creates.</returns> public static Color FromArgb(int alpha, int red, int green, int blue) { Color clr = new Color(); clr.a = alpha / 255F; clr.r = red / 255F; clr.g = green / 255F; clr.b = blue / 255F; return clr; } /// <summary> /// Creates a Color from the specified ARGB color values /// (alpha, red, green, and blue). /// </summary> /// <param name="cyan">The alpha component. Valid values are 0 through 1.</param> /// <param name="magenta">The red component. Valid values are 0 through 1.</param> /// <param name="yellow">The green component. Valid values are 0 through 1.</param> /// <param name="black">The blue component. Valid values are 0 through 1.</param> /// <returns>The Color that this method creates.</returns> public static Color FromArgb(double alpha, double red, double green, double blue) { Color clr = new Color(); clr.a = alpha; clr.r = red; clr.g = green; clr.b = blue; return clr; } /// <summary> /// Creates a Color from the specified CMYK color values /// (cyan, magenta, yellow, and black). /// </summary> /// <param name="cyan">The cyan component. Valid values are 0 through 1.</param> /// <param name="magenta">The magenta component. Valid values are 0 through 1.</param> /// <param name="yellow">The yellow component. Valid values are 0 through 1.</param> /// <param name="black">The black component. Valid values are 0 through 1.</param> /// <returns>The Color that this method creates.</returns> public static Color FromCmyk(double cyan, double magenta, double yellow, double black) { Color clr = new Color(); clr.c = cyan; clr.m = magenta; clr.y = yellow; clr.k = black; return clr; } /// <summary> /// Creates a Color from the specified gray level. /// </summary> /// <param name="gray">The gray component. Valid values are 0 through 1.</param> /// <returns>The Color that this method creates.</returns> public static Color FromCmyk(double gray) { Color clr = new Color(); clr.gray = gray; return clr; } /// <summary> /// Gets a system defined color /// </summary> public static Color AliceBlue { get { return FromKnownColor(System.Drawing.KnownColor.AliceBlue); } } /// <summary> /// Gets a system defined color /// </summary> public static Color AntiqueWhite { get { return FromKnownColor(System.Drawing.KnownColor.AntiqueWhite); } } }
Спасибо codeproject..
Что я уже пробовал:
Вот код назначения цвета во время проектирования, который работает, никаких проблем
new SolidBrush(Color.Aqua)
Так что теперь то, что я пытаюсь сделать, становится немного чище..
Таким образом, код, который я пытаюсь достичь, выглядит следующим образом.
new SolidBrush(combobox1.selecteditem)
Sergey Alexandrovich Kryukov
Как я вижу, это проприетарный коммерческий продукт. Зачем задавать такие вопросы здесь? Это не очень вероятно, что вы получите помощь. Скорее, вы можете потребовать некоторой помощи через их службу поддержки клиентов.
—СА
derstine
Мне очень жаль
Sergey Alexandrovich Kryukov
Нет, мне очень жаль. :-)
—СА