|
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ColorPicker;
namespace ColorPickerControls.Pickers
{
/// <summary>
/// Interaction logic for ColorPickerFull.xaml
/// </summary>
public partial class ColorPickerFull : UserControl
{
public static Type ClassType
{
get { return typeof(ColorPickerFull); }
}
#region InitialColor
public static DependencyProperty InitialColorProperty = DependencyProperty.Register("InitialColor", typeof(Color), ClassType,
new FrameworkPropertyMetadata(Colors.Transparent, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnInitialColorChanged));
[Category("ColorPicker")]
public Color InitialColor
{
get
{
return (Color)GetValue(InitialColorProperty);
}
set
{
SetValue(InitialColorProperty, value);
}
}
private static void OnInitialColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var cpf = (ColorPickerFull) d;
cpf.newCurrent.CurrentColor = (Color) e.NewValue ;
}
#endregion
public event EventHandler<EventArgs<Color>> SelectedColorChanged;
#region SelectedColor
public static DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), ClassType,
new FrameworkPropertyMetadata(Colors.Transparent, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedColorChanged));
[Category("ColorPicker")]
public Color SelectedColor
{
get
{
return (Color)GetValue(SelectedColorProperty);
}
set
{
SetValue(SelectedColorProperty, value);
}
}
private static void OnSelectedColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var cpf = (ColorPickerFull)d;
cpf.colorSelector.Color = (Color)e.NewValue;
if (cpf.SelectedColorChanged != null)
{
cpf.SelectedColorChanged(cpf, new EventArgs<Color>((Color)e.NewValue));
}
}
#endregion
[Category("ColorPicker")]
public ColorSelector.ESelectionRingMode SelectionRingMode
{
get { return colorSelector.SelectionRingMode; }
set { colorSelector.SelectionRingMode = value;}
}
public ColorPickerFull()
{
InitializeComponent();
SetBinding(SelectedColorProperty, "Color");
DataContext = colorSelector;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Written software for what seems like forever. I'm currenly infatuated with WPF. Hopefully my affections are returned.