Example #1
0
 private static void OnSelectedBrushChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
 {
     if ((obj != null) && (args.NewValue != null))
     {
         SmallColorPicker picker   = (SmallColorPicker)obj;
         SolidColorBrush  newValue = (SolidColorBrush)args.NewValue;
         if (picker.SelectedColor != newValue.Color)
         {
             picker.SelectedColor = newValue.Color;
         }
     }
 }
Example #2
0
        private static void OnSelectedColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            SmallColorPicker picker   = obj as SmallColorPicker;
            Color            newValue = (Color)args.NewValue;
            Color            oldValue = (Color)args.OldValue;

            if (newValue != oldValue)
            {
                if (((picker.Picker.SelectedValue == null) || (((Color)picker.Picker.SelectedValue) != newValue)) && !picker.Picker.Items.Contains(newValue))
                {
                    picker.Picker.Items.Add(newValue);
                }
                picker.SelectedBrush = new SolidColorBrush(newValue);
                picker.OnColorChanged(oldValue, newValue);
            }
        }