| 1 | using System; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Text; |
| 4 | using System.Windows; |
| 5 | using System.Windows.Controls; |
| 6 | using System.Windows.Media; |
| 7 | |
| 8 | namespace UI.Controls.Base |
| 9 | { |
| 10 | public class Icon : Control |
| 11 | { |
| 12 | public IconTypes IconType |
| 13 | { |
| 14 | get { return (IconTypes)GetValue(IconTypeProperty); } |
| 15 | set { SetValue(IconTypeProperty, value); } |
| 16 | } |
| 17 | public static readonly DependencyProperty IconTypeProperty = |
| 18 | DependencyProperty.Register("IconType", |
| 19 | typeof(IconTypes), |
| 20 | typeof(Icon), new PropertyMetadata(IconTypes.Back, new PropertyChangedCallback(OnIconTypeChanged))); |
| 21 | |
| 22 | private static void OnIconTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
| 23 | { |
| 24 | var control = d as Icon; |
| 25 | if (e.NewValue != e.OldValue) |
| 26 | { |
| 27 | control.Unicode = IconConverter.ToUnicode((IconTypes)e.NewValue); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public string Unicode |
| 32 | { |
| 33 | get { return (string)GetValue(UnicodeProperty); } |
| 34 | set { SetValue(UnicodeProperty, value); } |
| 35 | } |
| 36 | public static readonly DependencyProperty UnicodeProperty = |
| 37 | DependencyProperty.Register("Unicode", |
| 38 | typeof(string), |
| 39 | typeof(Icon), |
| 40 | new PropertyMetadata(IconConverter.ToUnicode(IconTypes.Back))); |
| 41 | public Icon() |
| 42 | { |
| 43 | DefaultStyleKey = typeof(Icon); |
| 44 | } |
| 45 | } |
| 46 | } |