using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace VisionUI.Layout { /// /// 각도 컨버터 (multiValue Converter) /// class AngleConverter : IMultiValueConverter { /// /// 컨버터 /// /// 값 ([0] (double)degree , [1] (bool)isReverse) /// /// /// /// 각도(degree) public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var degree = (double)values[0]; var isReverse = (bool)values[1]; if (isReverse) { return degree - 90; } return degree; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } /// /// Interaction logic for UCVisionCoordinate.xaml /// public partial class UCVisionCoordinate : UserControl { private static Type _classType = typeof(UCVisionCoordinate); /// /// 리버스인지 체크하는 DepednecyProperty /// public static readonly DependencyProperty IsReverseProperty = DependencyProperty.Register( nameof(IsReverse), typeof(bool), _classType, new PropertyMetadata(false, OnReverseChanged)); /// /// Reverse 확인 여부 버튼 변경 이벤트 핸들러 /// /// depedency 객체 /// depedencyProperty 변경 이벤트 private static void OnReverseChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var uc = d as UCVisionCoordinate; uc.IsReverse = (bool)e.NewValue; if (uc.IsReverse) { uc.XColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBE, 0x98)); uc.YColor = new SolidColorBrush(Color.FromRgb(0xBB, 0x26, 0x49)); } else { uc.XColor = new SolidColorBrush(Color.FromRgb(0xBB, 0x26, 0x49)); uc.YColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBE, 0x98)); } } /// /// 리버스 여부 /// public bool IsReverse { get { return (bool)GetValue(IsReverseProperty); } set { SetValue(IsReverseProperty, value); } } private SolidColorBrush _XColor = new SolidColorBrush(Color.FromRgb(0xBB, 0x26, 0x49)); /// /// X축 컬러 /// public SolidColorBrush XColor { get { return _XColor; } set { _XColor = value; } } private SolidColorBrush _YColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBE, 0x98)); /// /// Y축 컬러 /// public SolidColorBrush YColor { get { return _YColor; } set { _YColor = value; } } /// /// 각도 DepedencyProeprty /// public static readonly DependencyProperty DegreeProperty = DependencyProperty.Register( nameof(Degree), typeof(double), _classType, new PropertyMetadata(0.0, OnDegreeChanged)); /// /// 각도 DepedencyProperty 변경 이벤트 핸들러 /// /// depedency 객체 /// depedencyProperty 변경 이벤트 private static void OnDegreeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var uc = d as UCVisionCoordinate; uc.Degree = (double)e.NewValue; } /// /// 각도 /// public double Degree { get { return (int)GetValue(DegreeProperty); } set { SetValue(DegreeProperty, value); } } /// /// 생성자 /// public UCVisionCoordinate() { InitializeComponent(); DataContext = this; } } }