/* * Copyright (c) 2022 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ 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 AuroraUIComponent.UserControls { public enum eLEDColorType { RGB = 0, RYG = 1 }; public enum eLEDStatusVlaue { None = -1, Negative = 0, Another = 1, Positive = 2, }; /// /// UCLedLight.xaml에 대한 상호 작용 논리 /// public partial class UCLedLightCustom3 : UserControl { private SolidColorBrush[] _ColorList; public SolidColorBrush[] ColorList { get => _ColorList; } public UCLedLightCustom3() { InitializeComponent(); UpdateColors(); } private void UpdateColors() { if (_ColorList == null) { _ColorList = new SolidColorBrush[3]; } _ColorList[0] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(StatusColor0)); _ColorList[1] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(StatusColor1)); _ColorList[2] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(StatusColor2)); } public int LedStatusVal { get { return (int)GetValue(LedStatusValProperty); } set { SetValue(LedStatusValProperty, value); } } // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... public static readonly DependencyProperty LedStatusValProperty = DependencyProperty.Register(nameof(LedStatusVal), typeof(int), typeof(UCLedLightCustom3), new FrameworkPropertyMetadata( 0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public string StatusColor0 { get { return (string)GetValue(StatusColor0Property); } set { SetValue(StatusColor0Property, value); } } // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... public static readonly DependencyProperty StatusColor0Property = DependencyProperty.Register(nameof(StatusColor0), typeof(string), typeof(UCLedLightCustom3), new FrameworkPropertyMetadata( "#000000", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public string StatusColor1 { get { return (string)GetValue(StatusColor1Property); } set { SetValue(StatusColor1Property, value); } } // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... public static readonly DependencyProperty StatusColor1Property = DependencyProperty.Register(nameof(StatusColor1), typeof(string), typeof(UCLedLightCustom3), new FrameworkPropertyMetadata( "#000000", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public string StatusColor2 { get { return (string)GetValue(StatusColor2Property); } set { SetValue(StatusColor2Property, value); } } // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... public static readonly DependencyProperty StatusColor2Property = DependencyProperty.Register(nameof(StatusColor2), typeof(string), typeof(UCLedLightCustom3), new FrameworkPropertyMetadata( "#000000", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); } public class LedLightConverterCustom3 : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var baseColorList = new SolidColorBrush[3]; if (parameter is eLEDColorType.RYG) { baseColorList[0] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF0075")); // Red baseColorList[1] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#f0d41f")); // Yellow baseColorList[2] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#77D970")); // Green } else if (parameter is eLEDColorType.RGB) { baseColorList[0] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF0075")); // Red baseColorList[1] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#75FF00")); // Green baseColorList[2] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0075FF")); // Blue } else { baseColorList[0] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF0075")); // Red baseColorList[1] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#75FF00")); // Green baseColorList[2] = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0075FF")); // Blue } Color blackColor = (Color)ColorConverter.ConvertFromString("#000000"); SolidColorBrush BlackColor = new SolidColorBrush(blackColor); int LedStatusVal = (int)value; if (LedStatusVal >= 0 && LedStatusVal < 3) { return baseColorList[LedStatusVal]; } // 여기서 적절한 조건에 따라 색상을 선택하거나 계산하세요. return blackColor; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }