191 lines
8.2 KiB
C#
191 lines
8.2 KiB
C#
/*
|
|
* Copyright (c) 2022 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
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.Media;
|
|
|
|
namespace AuroraUIComponent.UserControls.KeyValueBase
|
|
{
|
|
public abstract class UCKeyValueBase : UserControl
|
|
{
|
|
public static readonly DependencyProperty KeyHorizontalAlignmentProperty
|
|
= DependencyProperty.Register(
|
|
nameof(KeyHorizontalAlignment),
|
|
typeof(HorizontalAlignment),
|
|
typeof(UCKeyValueBase),
|
|
new PropertyMetadata(HorizontalAlignment.Left));
|
|
|
|
public HorizontalAlignment KeyHorizontalAlignment {
|
|
get { return (HorizontalAlignment)GetValue(KeyHorizontalAlignmentProperty); }
|
|
set { SetValue(KeyHorizontalAlignmentProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty ValueHorizontalAlignmentProperty
|
|
= DependencyProperty.Register(
|
|
nameof(ValueHorizontalAlignment),
|
|
typeof(HorizontalAlignment),
|
|
typeof(UCKeyValueBase),
|
|
new PropertyMetadata(HorizontalAlignment.Center));
|
|
|
|
public HorizontalAlignment ValueHorizontalAlignment {
|
|
get { return (HorizontalAlignment)GetValue(ValueHorizontalAlignmentProperty); }
|
|
set { SetValue(ValueHorizontalAlignmentProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty KeyTextProperty
|
|
= DependencyProperty.Register(
|
|
nameof(KeyText),
|
|
typeof(string),
|
|
typeof(UCKeyValueBase),
|
|
new PropertyMetadata(string.Empty, OnKeyTextChanged));
|
|
|
|
public string KeyText {
|
|
get { return (string)GetValue(KeyTextProperty); }
|
|
set { SetValue(KeyTextProperty, value); }
|
|
}
|
|
|
|
private static void OnKeyTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
var control = d as UCKeyValueBase;
|
|
control.KeyTextChanged((string)e.NewValue);
|
|
}
|
|
|
|
public static readonly DependencyProperty KeyTextSizeProperty
|
|
= DependencyProperty.Register(
|
|
nameof(KeyTextSize),
|
|
typeof(double),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
UCCommonDef.UCKeyValueCommon.DEFAULT_FONTSIZE_KEY,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public double KeyTextSize {
|
|
get { return (double)GetValue(KeyTextSizeProperty); }
|
|
set { SetValue(KeyTextSizeProperty, value); }
|
|
}
|
|
|
|
|
|
public static readonly DependencyProperty ValueTextSizeProperty
|
|
= DependencyProperty.Register(
|
|
nameof(ValueTextSize),
|
|
typeof(double),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
UCCommonDef.UCKeyValueCommon.DEFAULT_FONTSIZE_VALUE,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public double ValueTextSize {
|
|
get { return (double)GetValue(ValueTextSizeProperty); }
|
|
set { SetValue(ValueTextSizeProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty KeyTextWidthProperty
|
|
= DependencyProperty.Register(
|
|
nameof(KeyTextWidth),
|
|
typeof(string),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
UCCommonDef.UCKeyValueCommon.DEFAULT_WIDTH_KEY,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public string KeyTextWidth {
|
|
get { return (string)GetValue(KeyTextWidthProperty); }
|
|
set { SetValue(KeyTextWidthProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty ValueTextWidthProperty
|
|
= DependencyProperty.Register(
|
|
nameof(ValueTextWidth),
|
|
typeof(string),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
UCCommonDef.UCKeyValueCommon.DEFAULT_WIDTH_VALUE,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public string ValueTextWidth {
|
|
get { return (string)GetValue(ValueTextWidthProperty); }
|
|
set { SetValue(ValueTextWidthProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty KeyTextFgColorProperty
|
|
= DependencyProperty.Register(
|
|
nameof(KeyTextFgColor),
|
|
typeof(SolidColorBrush),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
UCCommonDef.UCKeyValueCommon.DEFAULT_KEY_TEXTCOLOR,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public SolidColorBrush KeyTextFgColor {
|
|
get { return (SolidColorBrush)GetValue(KeyTextFgColorProperty); }
|
|
set { SetValue(KeyTextFgColorProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty ValueTextFgColorProperty
|
|
= DependencyProperty.Register(
|
|
nameof(ValueTextFgColor),
|
|
typeof(SolidColorBrush),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
Brushes.White,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public SolidColorBrush ValueTextFgColor {
|
|
get { return (SolidColorBrush)GetValue(ValueTextFgColorProperty); }
|
|
set { SetValue(ValueTextFgColorProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty KeyTextBgColorProperty
|
|
= DependencyProperty.Register(
|
|
nameof(KeyTextBgColor),
|
|
typeof(SolidColorBrush),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
Brushes.Transparent,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public SolidColorBrush KeyTextBgColor {
|
|
get { return (SolidColorBrush)GetValue(KeyTextBgColorProperty); }
|
|
set { SetValue(KeyTextBgColorProperty, value); }
|
|
}
|
|
|
|
public static readonly DependencyProperty ValueTextBgColorProperty
|
|
= DependencyProperty.Register(
|
|
nameof(ValueTextBgColor),
|
|
typeof(SolidColorBrush),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
Brushes.Transparent,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public SolidColorBrush ValueTextBgColor {
|
|
get { return (SolidColorBrush)GetValue(ValueTextBgColorProperty); }
|
|
set { SetValue(ValueTextBgColorProperty, value); }
|
|
}
|
|
|
|
|
|
public static readonly DependencyProperty IsReadOnlyProperty
|
|
= DependencyProperty.Register(
|
|
nameof(IsReadOnly),
|
|
typeof(bool),
|
|
typeof(UCKeyValueBase),
|
|
new FrameworkPropertyMetadata(
|
|
false,
|
|
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
|
|
public bool IsReadOnly {
|
|
get { return (bool)GetValue(IsReadOnlyProperty); }
|
|
set { SetValue(IsReadOnlyProperty, value); }
|
|
}
|
|
|
|
protected abstract void KeyTextChanged(string newValue);
|
|
}
|
|
}
|