private static void OnSelectedColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { // Debug.WriteLine("OnSelectedColorChanged"); SmallColorPicker cp = obj as SmallColorPicker; Debug.Assert(cp != null); Color newColor = (Color)args.NewValue; Color oldColor = (Color)args.OldValue; if (newColor == oldColor) { return; } // When the SelectedColor changes, set the selected value of the combo box if (cp.Picker.SelectedValue == null || (Color)cp.Picker.SelectedValue != newColor) { // Add the color if not found if (!cp.Picker.Items.Contains(newColor)) { cp.Picker.Items.Add(newColor); } } // Also update the brush cp.SelectedBrush = new SolidColorBrush(newColor); cp.OnColorChanged(oldColor, newColor); }
private static void OnSelectedBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { // Debug.WriteLine("OnSelectedBrushChanged"); SmallColorPicker cp = (SmallColorPicker)obj; SolidColorBrush newBrush = (SolidColorBrush)args.NewValue; // SolidColorBrush oldBrush = (SolidColorBrush)args.OldValue; if (cp.SelectedColor != newBrush.Color) { cp.SelectedColor = newBrush.Color; } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.ThisColorPicker = ((OpenSourceControls.SmallColorPicker)(target)); return; case 2: this.Picker = ((System.Windows.Controls.ComboBox)(target)); return; } this._contentLoaded = true; }
/// <summary> /// /// </summary> /// <param name="parent"></param> public ColorsGlassWindow(Window parent,int id) { InitializeComponent(); this.WindowStartupLocation = WindowStartupLocation.CenterScreen; this.parentWin = parent; List<SeriesColor> series; series = ((IndicadorWindow)this.parentWin).chart.obtenerSeries(); foreach(SeriesColor serTmp in series) { Label l = new Label(); l.Content = serTmp.nombre; l.Foreground = new SolidColorBrush(Colors.White); spColors.Children.Add(l); SmallColorPicker sm = new SmallColorPicker(); sm.Width = 50; sm.SelectedColor = serTmp.color; spColors.Children.Add(sm); } }