/// <summary> /// Sets one DeviceKeys key with a specific color on the bitmap /// </summary> /// <param name="key">DeviceKey to be set</param> /// <param name="color">Color to be used</param> private void SetOneKey(Devices.DeviceKeys key, Color color) { Bitmaping keymaping = Effects.GetBitmappingFromDeviceKey(key); if (keymaping.Equals(new Bitmaping(0, 0, 0, 0)) && key == Devices.DeviceKeys.Peripheral) { peripheral = color; } else { if (keymaping.topleft_y < 0 || keymaping.bottomright_y > Effects.canvas_height || keymaping.topleft_x < 0 || keymaping.bottomright_x > Effects.canvas_width) { Global.logger.LogLine("Coudln't set key color " + key.ToString(), Logging_Level.Warning); return; } else { using (Graphics g = Graphics.FromImage(colormap)) { Rectangle keyarea = new Rectangle(keymaping.topleft_x, keymaping.topleft_y, keymaping.bottomright_x - keymaping.topleft_x, keymaping.bottomright_y - keymaping.topleft_y); g.FillRectangle(new SolidBrush(color), keyarea); needsRender = true; } } } }
/// <summary> /// Sets one DeviceKeys key with a specific color on the bitmap /// </summary> /// <param name="key">DeviceKey to be set</param> /// <param name="color">Color to be used</param> /// <returns>Itself</returns> private EffectLayer SetOneKey(Devices.DeviceKeys key, Color color) { BitmapRectangle keymaping = Effects.GetBitmappingFromDeviceKey(key); if (key == Devices.DeviceKeys.Peripheral) { peripheral = color; using (Graphics g = Graphics.FromImage(colormap)) { foreach (Devices.DeviceKeys peri_key in possible_peripheral_keys) { BitmapRectangle peri_keymaping = Effects.GetBitmappingFromDeviceKey(peri_key); if (peri_keymaping.IsValid) { g.FillRectangle(new SolidBrush(color), peri_keymaping.Rectangle); } } needsRender = true; } } else { if (keymaping.Top < 0 || keymaping.Bottom > Effects.canvas_height || keymaping.Left < 0 || keymaping.Right > Effects.canvas_width) { Global.logger.LogLine("Coudln't set key color " + key.ToString(), Logging_Level.Warning); return(this);; } else { using (Graphics g = Graphics.FromImage(colormap)) { g.FillRectangle(new SolidBrush(color), keymaping.Rectangle); needsRender = true; } } } return(this); }