2026-06-05 13:44:39 +09:00

138 lines
5.0 KiB
C#

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 {
/// <summary>
/// 각도 컨버터 (multiValue Converter)
/// </summary>
class AngleConverter : IMultiValueConverter {
/// <summary>
/// 컨버터
/// </summary>
/// <param name="values">값 ([0] (double)degree , [1] (bool)isReverse)</param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns>각도(degree)</returns>
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();
}
}
/// <summary>
/// Interaction logic for UCVisionCoordinate.xaml
/// </summary>
public partial class UCVisionCoordinate : UserControl {
private static Type _classType = typeof(UCVisionCoordinate);
/// <summary>
/// 리버스인지 체크하는 DepednecyProperty
/// </summary>
public static readonly DependencyProperty IsReverseProperty
= DependencyProperty.Register(
nameof(IsReverse),
typeof(bool),
_classType,
new PropertyMetadata(false, OnReverseChanged));
/// <summary>
/// Reverse 확인 여부 버튼 변경 이벤트 핸들러
/// </summary>
/// <param name="d">depedency 객체</param>
/// <param name="e">depedencyProperty 변경 이벤트</param>
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));
}
}
/// <summary>
/// 리버스 여부
/// </summary>
public bool IsReverse {
get { return (bool)GetValue(IsReverseProperty); }
set { SetValue(IsReverseProperty, value); }
}
private SolidColorBrush _XColor = new SolidColorBrush(Color.FromRgb(0xBB, 0x26, 0x49));
/// <summary>
/// X축 컬러
/// </summary>
public SolidColorBrush XColor {
get { return _XColor; }
set { _XColor = value; }
}
private SolidColorBrush _YColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBE, 0x98));
/// <summary>
/// Y축 컬러
/// </summary>
public SolidColorBrush YColor {
get { return _YColor; }
set { _YColor = value; }
}
/// <summary>
/// 각도 DepedencyProeprty
/// </summary>
public static readonly DependencyProperty DegreeProperty
= DependencyProperty.Register(
nameof(Degree),
typeof(double),
_classType,
new PropertyMetadata(0.0, OnDegreeChanged));
/// <summary>
/// 각도 DepedencyProperty 변경 이벤트 핸들러
/// </summary>
/// <param name="d">depedency 객체</param>
/// <param name="e">depedencyProperty 변경 이벤트</param>
private static void OnDegreeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
var uc = d as UCVisionCoordinate;
uc.Degree = (double)e.NewValue;
}
/// <summary>
/// 각도
/// </summary>
public double Degree {
get { return (int)GetValue(DegreeProperty); }
set { SetValue(DegreeProperty, value); }
}
/// <summary>
/// 생성자
/// </summary>
public UCVisionCoordinate() {
InitializeComponent();
DataContext = this;
}
}
}