public Light(int x, int y, LightCircuit circuit, LightColor color, LightShape shape) { Assembly assembly = Assembly.GetExecutingAssembly(); string lightName = Enum.GetName(color.GetType(), color).ToLower(); string resourceOn = string.Format("JamesAllen.XmasLights.Images.{0}_on.png", lightName); string resourceOff = string.Format("JamesAllen.XmasLights.Images.{0}_off.png", lightName); Stream streamOn = assembly.GetManifestResourceStream(resourceOn); Stream streamOff = assembly.GetManifestResourceStream(resourceOff); imageOn = (Image)Bitmap.FromStream(streamOn); imageOff = (Image)Bitmap.FromStream(streamOff); this.position = new Point(x, y); this.circuit = circuit; this.color = color; this.shape = shape; }
public static string GetDescription(this LightColor color) { var attributes = color.GetType().GetField(color.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return((attributes[0] as DescriptionAttribute)?.Description ?? color.ToString()); }