/* * Copyright (c) 2025 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ using AuroraUIComponent.UserControls.KeyValueBase; using Hermes.Functional; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; 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 { /// /// Interaction logic for UCKeyContentView.xaml /// public partial class UCKeyContentView : UCKeyValueBase { private event RoutedEventHandler FoldingChangedEvent; // Binding 한 IsFolding Property changed event public UCKeyContentView() { InitializeComponent(); MainToggleButton.Checked += EvtHandlerMainToggleButtonChecked; } #region Depedency Properties #region Content View 관련 Properties public static readonly DependencyProperty ContentViewProperty = DependencyProperty.Register( nameof(ContentView), typeof(object), typeof(UCKeyContentView), new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// 넣고자 하는 View Item /// public object ContentView { get { return (object)GetValue(ContentViewProperty); } set { SetValue(ContentViewProperty, value); } } #endregion #region Util 관련 properties public static readonly DependencyProperty IsShowHelperProperty = DependencyProperty.Register( nameof(IsShowHelper), typeof(bool), typeof(UCKeyContentView), new FrameworkPropertyMetadata( false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Helper Button 보여줄 지 여부 /// public bool IsShowHelper { get { return (bool)GetValue(IsShowHelperProperty); } set { SetValue(IsShowHelperProperty, value); } } public static readonly DependencyProperty UseFoldingProperty = DependencyProperty.Register( nameof(UseFolding), typeof(bool), typeof(UCKeyContentView), new FrameworkPropertyMetadata( true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Folding (접었다 폈다) 기능 사용 여부 /// public bool UseFolding { get { return (bool)GetValue(UseFoldingProperty); } set { SetValue(UseFoldingProperty, value); } } public static readonly DependencyProperty IsFoldingProperty = DependencyProperty.Register( nameof(IsFolding), typeof(bool), typeof(UCKeyContentView), new FrameworkPropertyMetadata( false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// 현재 Folding 상태 여부 /// public bool IsFolding { get { return (bool)GetValue(IsFoldingProperty); } set { //if(IsFolding != value && UseFoldingButton) { TextValue.Visibility = value ? Visibility.Collapsed : Visibility.Visible; } if (UseFoldingButton) { if ((bool)GetValue(IsFoldingProperty) != value) { SetValue(IsFoldingProperty, value); if (FoldingChangedEvent != null) { FoldingChangedEvent(this, new RoutedEventArgs()); } } } } } #endregion #region Folding Button 관련 Properties public static readonly DependencyProperty UseFoldingButtonProperty = DependencyProperty.Register( nameof(UseFoldingButton), typeof(bool), typeof(UCKeyContentView), new FrameworkPropertyMetadata( true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Folding Button 사용할 지 여부 ( Key Value가 아닌 별도 작은 button ) /// public bool UseFoldingButton { get { return (bool)GetValue(UseFoldingButtonProperty); } set { SetValue(UseFoldingButtonProperty, value); } } public static readonly DependencyProperty FoldingBtnStyleProperty = DependencyProperty.Register( nameof(FoldingBtnStyle), typeof(Style), typeof(UCKeyContentView), new PropertyMetadata(null)); /// /// Folding Button 스타일 ( Key Value가 아닌 별도 작은 button ) /// public Style FoldingBtnStyle { get { return (Style)GetValue(FoldingBtnStyleProperty); } set { SetValue(FoldingBtnStyleProperty, value); } } public static readonly DependencyProperty FoldingBtnMarginProperty = DependencyProperty.Register( nameof(FoldingBtnMargin), typeof(Thickness), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new Thickness(0), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Folding Button Margin ( Key Value가 아닌 별도 작은 button ) /// public Thickness FoldingBtnMargin { get { return (Thickness)GetValue(FoldingBtnMarginProperty); } set { SetValue(FoldingBtnMarginProperty, value); } } public static readonly DependencyProperty FoldingBtnWidthProperty = DependencyProperty.Register( nameof(FoldingBtnWidth), typeof(double), typeof(UCKeyContentView), new FrameworkPropertyMetadata( 10.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Folding Button Width ( Key Value가 아닌 별도 작은 button ) /// public double FoldingBtnWidth { get { return (double)GetValue(FoldingBtnWidthProperty); } set { SetValue(FoldingBtnWidthProperty, value); } } public static readonly DependencyProperty FoldingBtnHeightProperty = DependencyProperty.Register( nameof(FoldingBtnHeight), typeof(double), typeof(UCKeyContentView), new FrameworkPropertyMetadata( 10.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Folding Button Margin ( Key Value가 아닌 별도 작은 button ) /// public double FoldingBtnHeight { get { return (double)GetValue(FoldingBtnHeightProperty); } set { SetValue(FoldingBtnHeightProperty, value); } } #endregion #region Key / Value Content 관련 Properties public static readonly DependencyProperty KeyTextMarginProperty = DependencyProperty.Register( nameof(KeyTextMargin), typeof(Thickness), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new Thickness(5,2,5,2), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Value Content Margin /// public Thickness KeyTextMargin { get { return (Thickness)GetValue(KeyTextMarginProperty); } set { SetValue(KeyTextMarginProperty, value); } } public static readonly DependencyProperty ValueMarginProperty = DependencyProperty.Register( nameof(ValueMargin), typeof(Thickness), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new Thickness(0), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Content Key를 담고있는 Toggle Button의 Border의 brush color /// public SolidColorBrush KeyBorderBrushColor { get { return (SolidColorBrush)GetValue(KeyBorderBrushColorProperty); } set { SetValue(KeyBorderBrushColorProperty, value); } } public static readonly DependencyProperty KeyBorderBrushColorProperty = DependencyProperty.Register( nameof(KeyBorderBrushColor), typeof(SolidColorBrush), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new SolidColorBrush(Colors.Transparent), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); /// /// Folding Button Margin ( Key Value가 아닌 별도 작은 button ) /// public Thickness ValueMargin { get { return (Thickness)GetValue(ValueMarginProperty); } set { SetValue(ValueMarginProperty, value); } } public static readonly DependencyProperty ValueVerticalAlignmentProperty = DependencyProperty.Register( nameof(ValueVerticalAlignment), typeof(VerticalAlignment), typeof(UCKeyContentView), new PropertyMetadata(VerticalAlignment.Center)); /// /// Content Value의 Vertical Alignment brush color /// public VerticalAlignment ValueVerticalAlignment { get { return (VerticalAlignment)GetValue(ValueVerticalAlignmentProperty); } set { SetValue(ValueVerticalAlignmentProperty, value); } } public static readonly DependencyProperty ValueBorderBrushColorProperty = DependencyProperty.Register( nameof(ValueBorderBrushColor), typeof(SolidColorBrush), typeof(UCKeyContentView), new FrameworkPropertyMetadata( (SolidColorBrush)Application.Current.Resources["MahApps.Brushes.Aurora.Datagrid.Border"], FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); /// /// Content Value를 담고있는 Border의 brush color /// public SolidColorBrush ValueBorderBrushColor { get { return (SolidColorBrush)GetValue(ValueBorderBrushColorProperty); } set { SetValue(ValueBorderBrushColorProperty, value); } } public static readonly DependencyProperty ValueBorderThicknessProperty = DependencyProperty.Register( nameof(ValueBorderThickness), typeof(Thickness), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new Thickness(2), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Content Value를 담고있는 Border의 Thickness /// ( 기본 2 , Main Key Toggle Button의 Border size 가 2) /// public Thickness ValueBorderThickness { get { return (Thickness)GetValue(ValueBorderThicknessProperty); } set { SetValue(ValueBorderThicknessProperty, value); } } public static readonly DependencyProperty KeyBorderCornerRadiusProperty = DependencyProperty.Register( nameof(KeyBorderCornerRadius), typeof(CornerRadius), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new CornerRadius(0), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault )); /// /// Content Value를 담고있는 Border의 cornerRadius /// ( 기본 2 , Main Key Toggle Button의 Border size 가 2) /// public CornerRadius KeyBorderCornerRadius { get { return (CornerRadius)GetValue(KeyBorderCornerRadiusProperty); } set { SetValue(KeyBorderCornerRadiusProperty, value); } } #endregion #region 색상 /// /// Key를 담고있는 Toggle Button의 Border의 brush color /// public SolidColorBrush KeyTextIsMouseOverBgColor { get { return (SolidColorBrush)GetValue(KeyTextIsMouseOverBgColorProperty); } set { SetValue(KeyTextIsMouseOverBgColorProperty, value); } } public static readonly DependencyProperty KeyTextIsMouseOverBgColorProperty = DependencyProperty.Register( nameof(KeyTextIsMouseOverBgColor), typeof(SolidColorBrush), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new SolidColorBrush(Colors.Gray), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); public SolidColorBrush KeyTextCheckedBgColor { get { return (SolidColorBrush)GetValue(KeyTextCheckedBgColorProperty); } set { SetValue(KeyTextCheckedBgColorProperty, value); } } public static readonly DependencyProperty KeyTextCheckedBgColorProperty = DependencyProperty.Register( nameof(KeyTextCheckedBgColor), typeof(SolidColorBrush), typeof(UCKeyContentView), new FrameworkPropertyMetadata( new SolidColorBrush(Colors.DarkRed), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); #endregion #endregion #region 기능성 Methods protected override void KeyTextChanged(string newValue) { } /// /// Folding 변경하기 /// /// True : 접기 | False : 펴기 public void ChangeFold(bool fold) { IsFolding = fold; } /// /// (외부에서 접근) Folding Change 될 때 Event handler Setting 하기 /// /// 연결할 Event handler public void SetFoldingChangedEventHandler(RoutedEventHandler eventHandler) { MainToggleButton.Click += eventHandler; FoldingChangedEvent += eventHandler; } private void EvtHandlerMainToggleButtonChecked(object sender, RoutedEventArgs e) { if (!UseFolding && sender is ToggleButton toggleBtn) { toggleBtn.IsChecked = false; } } #endregion } }