using System; using System.Windows; using System.Windows.Media; using System.Windows.Controls; using SHJX.Service.Common.UserColor; using SHJX.Service.Common.Utils; namespace SHJX.Service.Library.Views { /// /// CustomEllipse.xaml 的交互逻辑 /// public partial class CustomEllipse : UserControl { public CustomEllipse() { InitializeComponent(); } #region Width public double CapWidth { get => (double)GetValue(CapWidthProperty); set => SetValue(CapWidthProperty, value); } public static readonly DependencyProperty CapWidthProperty = DependencyProperty.Register( nameof(CapWidth), typeof(double), typeof(CustomEllipse), new UIPropertyMetadata(0.0, (obj, args) => { var control = obj as CustomEllipse; var path = control?.cap; path.Width = Convert.ToDouble(args.NewValue); })); #endregion #region Height public double CapHeight { get => (double)GetValue(CapHeightProperty); set => SetValue(CapHeightProperty, value); } public static readonly DependencyProperty CapHeightProperty = DependencyProperty.Register( nameof(CapHeight), typeof(double), typeof(CustomEllipse), new UIPropertyMetadata(0.0, (obj, args) => { var control = obj as CustomEllipse; var path = control?.cap; path.Height = Convert.ToDouble(args.NewValue); })); #endregion #region Fill public string CapFill { get => (string)GetValue(CapFillProperty); set => SetValue(CapFillProperty, value); } public static readonly DependencyProperty CapFillProperty = DependencyProperty.Register( nameof(CapFill), typeof(string), typeof(CustomEllipse), new UIPropertyMetadata(string.Empty, (obj, args) => { var control = obj as CustomEllipse; var path = control?.cap; path.Fill = args.NewValue.ToString().ConvertToBrush(); })); #endregion #region Stroke public string CapStroke { get => (string)GetValue(CapStrokeProperty); set => SetValue(CapStrokeProperty, value); } public static readonly DependencyProperty CapStrokeProperty = DependencyProperty.Register( nameof(CapStroke), typeof(string), typeof(CustomEllipse), new UIPropertyMetadata(string.Empty, (obj, args) => { var control = obj as CustomEllipse; var path = control?.cap; path.Stroke = args.NewValue.ToString().ConvertToBrush(); })); #endregion #region StrokeThickness public double CapStrokeThickness { get => (double)GetValue(CapStrokeThicknessProperty); set => SetValue(CapStrokeThicknessProperty, value); } public static readonly DependencyProperty CapStrokeThicknessProperty = DependencyProperty.Register( nameof(CapStrokeThickness), typeof(double), typeof(CustomEllipse), new UIPropertyMetadata(0.0, (obj, args) => { var control = obj as CustomEllipse; var path = control?.cap; path.StrokeThickness = Convert.ToDouble(args.NewValue); })); #endregion #region Info public string Info { get => (string)GetValue(InfoProperty); set => SetValue(InfoProperty, value); } public static readonly DependencyProperty InfoProperty = DependencyProperty.Register(nameof(Info), typeof(string), typeof(CustomEllipse), new UIPropertyMetadata(string.Empty, (obj, args) => { CustomEllipse control = obj as CustomEllipse; TextBlock path = control?.txt_info; path.Text = args.NewValue.ToString(); })); #endregion } }