/// <summary> /// Initializes a new instance of the <see cref="Paint.ColorPickerDefinition"/> class. /// </summary> /// <param name='colorPickerDefinition'> Layout of the color setter as defined within a xml file. </param> /// <param name='scale' iPad size scale - i.e.2 for retina and 1 for normal - allows us to multiply up the layout /> public ColorPickerDefinition(ToolboxLayoutDefinitionPaintToolsColorPickersColorPicker colorPickerDefinition, int scale) { this.Bounds = new Rectangle( (int)colorPickerDefinition.Region.Location.X * scale, (int)colorPickerDefinition.Region.Location.Y * scale, colorPickerDefinition.Region.Size.Width * scale, colorPickerDefinition.Region.Size.Height * scale); this.BackgroundColor = new Color( colorPickerDefinition.Region.BackgroundColor.Red, colorPickerDefinition.Region.BackgroundColor.Green, colorPickerDefinition.Region.BackgroundColor.Blue); this.BorderColor = new Color( colorPickerDefinition.Region.Border.Color.Red, colorPickerDefinition.Region.Border.Color.Green, colorPickerDefinition.Region.Border.Color.Blue); this.BorderWidth = colorPickerDefinition.Region.Border.Width * scale; }
/// <summary> /// Creates the color pickers. /// </summary> /// <param name='colorSelector' The colorSelector control we need to update when ever the user picks a color /> /// <param name='layoutColorPickers' Layout information for each color picker control /> private void CreateColorPickers(ColorSelector colorSelector, ToolboxLayoutDefinitionPaintToolsColorPickersColorPicker[] layoutColorPickers) { foreach (var layoutColorPicker in layoutColorPickers) { var colorPicker = new ColorPicker(this.GraphicsDisplay, new ColorPickerDefinition(layoutColorPicker, this.Scale)); colorPicker.ColorSelected += (sender, e) => { colorSelector.Color = colorPicker.Color; }; this.AddTool(colorPicker); } }