private ColorPaletteButton generateColorButton(int columnNumber, Color fillColor, ColorPaletteButton.StackPosition position) { ColorPaletteButton button = new ColorPaletteButton(fillColor, position); button.ColorSelected += this.onColorButtonColorSelected; button.Width = this._buttonSize.Width; button.Height = this._buttonSize.Height; button.Margin = new Thickness(2.0); Grid.SetColumn(button, columnNumber); return(button); }
private void OnSelectedColorBrushPropertyChanged() { if (this._colorButtons != null) { foreach (ColorPaletteButton btn in this._colorButtons) { btn.IsSelected = false; // IsCurrentSelectedColor(btn.Fill.Color); if (btn.IsSelected) _lastSelectedColorButton = btn; } } if (ColorSelector != null) { if(SelectedColorBrush != null) ColorSelector.Color = SelectedColorBrush.Color; } }
private void onColorButtonColorSelected(object sender, ColorChosenEventArgs args) { //if (_lastSelectedColorButton != null) // unselect the previous button // _lastSelectedColorButton.IsSelected = false; SelectedColorBrush = new SolidColorBrush(args.Color); OnColorPicked(args); _lastSelectedColorButton = sender as ColorPaletteButton; //if (_lastSelectedColorButton != null) // select this button // _lastSelectedColorButton.IsSelected = true; if (ColorSelector != null) { ColorSelector.InitialColor = ColorSelector.Color = args.Color; } }
private void buildStandardColorsGrid() { if (StandardColorsGrid == null || Colors == null) { return; } StandardColorsGrid.Children.Clear(); int rowNum = 0; int columnNum = 0; RowDefinition rowDefinition = new RowDefinition(); rowDefinition.Height = new GridLength(0.0, 0); StandardColorsGrid.RowDefinitions.Add(rowDefinition); int themeColorsCount = ThemeColors != null ? ThemeColors.Count : 7; foreach (Color standardColor in Colors) { ColumnDefinition definition = new ColumnDefinition(); definition.Width = new GridLength(0.0, 0); StandardColorsGrid.ColumnDefinitions.Add(definition); ColorPaletteButton standardColorButton = generateColorButton(columnNum, rowNum, standardColor, ColorPaletteButton.StackPosition.None); standardColorButton.Margin = new Thickness(2.0); StandardColorsGrid.Children.Add(standardColorButton); columnNum++; // Keep the number of columns equal to the number of theme colors if ((columnNum >= themeColorsCount) && themeColorsCount > 0 && (columnNum != Colors.Count - 1)) { // move to next row rowNum++; columnNum = 0; rowDefinition = new RowDefinition(); rowDefinition.Height = new GridLength(0.0, 0); StandardColorsGrid.RowDefinitions.Add(rowDefinition); } } }
private void OnSelectedColorBrushPropertyChanged() { if (this._colorButtons != null) { foreach (ColorPaletteButton btn in this._colorButtons) { btn.IsSelected = false; // IsCurrentSelectedColor(btn.Fill.Color); if (btn.IsSelected) { _lastSelectedColorButton = btn; } } } if (ColorSelector != null) { if (SelectedColorBrush != null) { ColorSelector.Color = SelectedColorBrush.Color; } } }
private ColorPaletteButton generateColorButton(int columnNumber, int rowNum, Color fillColor, ColorPaletteButton.StackPosition position) { ColorPaletteButton button = new ColorPaletteButton(fillColor, position); button.IsSelected = false; // IsCurrentSelectedColor(fillColor); button.ColorSelected += this.onColorButtonColorSelected; button.Width = this._buttonSize.Width; button.Height = this._buttonSize.Height; Grid.SetColumn(button, columnNumber); Grid.SetRow(button, rowNum); if (rowNum == 0) { button.Margin = new Thickness(2.0, 2.0, 2.0, 0.0); return(button); } if (rowNum < (this.MaxRows - 1)) { button.Margin = new Thickness(2.0, 0.0, 2.0, 0.0); return(button); } button.Margin = new Thickness(2.0, 0.0, 2.0, 2.0); return(button); }
private ColorPaletteButton generateColorButton(int columnNumber, int rowNum, Color fillColor, ColorPaletteButton.StackPosition position) { ColorPaletteButton button = new ColorPaletteButton(fillColor, position); button.IsSelected = false; // IsCurrentSelectedColor(fillColor); button.ColorSelected += this.onColorButtonColorSelected; button.Width = this._buttonSize.Width; button.Height = this._buttonSize.Height; Grid.SetColumn(button, columnNumber); Grid.SetRow(button, rowNum); if (rowNum == 0) { button.Margin = new Thickness(2.0, 2.0, 2.0, 0.0); return button; } if (rowNum < (this.MaxRows - 1)) { button.Margin = new Thickness(2.0, 0.0, 2.0, 0.0); return button; } button.Margin = new Thickness(2.0, 0.0, 2.0, 2.0); return button; }
private ColorPaletteButton generateColorButton(int columnNumber, Color fillColor, ColorPaletteButton.StackPosition position) { ColorPaletteButton button = new ColorPaletteButton(fillColor, position); button.ColorSelected += this.onColorButtonColorSelected; button.Width = this._buttonSize.Width; button.Height= this._buttonSize.Height; button.Margin = new Thickness(2.0); Grid.SetColumn(button, columnNumber); return button; }
private void onColorButtonColorSelected(object sender, ColorChosenEventArgs args) { //if (_lastSelectedColorButton != null) // unselect the previous button // _lastSelectedColorButton.IsSelected = false; SelectedColorBrush = new SolidColorBrush(args.Color); OnColorPicked(args); _lastSelectedColorButton = sender as ColorPaletteButton; //if (_lastSelectedColorButton != null) // select this button // _lastSelectedColorButton.IsSelected = true; if (ColorSelector != null) ColorSelector.InitialColor = ColorSelector.Color = args.Color; }
/// <summary> /// IsSelectedProperty property changed handler. /// </summary> /// <param name="d">ColorPaletteButton that changed its IsSelected.</param> /// <param name="e">Event arguments.</param> private static void OnIsSelectedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ColorPaletteButton source = d as ColorPaletteButton; source.UpdateBorderOnIsSelectedChanged(); }