提交用户部分代码

This commit is contained in:
chfei committed 2026-11-13 15:51:16 +08:00
1 parent 9b9e4cbd82
commit 127fc22de5
26 files changed
+1110 -206

No files matched your search

@@ -0,0 +1,127 @@
using MAX.Common.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace Store.Management.Framework.Controls
{
internal class HorizontalIconText : Control
{
public string Icon
{
get => (string)GetValue(IconProperty);
set => SetValue(IconProperty, value);
}
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
nameof(Icon),
typeof(string),
typeof(HorizontalIconText),
new PropertyMetadata(null, OnOnIconChanged)
);
public bool ShowIcon
{
get => (bool)GetValue(ShowIconProperty);
private set => SetValue(ShowIconPropertyKey, value);
}
private static readonly DependencyPropertyKey ShowIconPropertyKey = DependencyProperty.RegisterReadOnly(
nameof(ShowIcon),
typeof(bool),
typeof(HorizontalIconText),
new PropertyMetadata(false)
);
public static readonly DependencyProperty ShowIconProperty = ShowIconPropertyKey.DependencyProperty;
public bool ShowSpace
{
get => (bool)GetValue(ShowSpaceProperty);
private set => SetValue(ShowSpacePropertyKey, value);
}
private static readonly DependencyPropertyKey ShowSpacePropertyKey = DependencyProperty.RegisterReadOnly(
nameof(ShowSpace),
typeof(bool),
typeof(HorizontalIconText),
new PropertyMetadata(true)
);
public static readonly DependencyProperty ShowSpaceProperty = ShowSpacePropertyKey.DependencyProperty;
public string Text
{
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
nameof(Text),
typeof(string),
typeof(HorizontalIconText),
new PropertyMetadata(string.Empty)
);
public double IconSize
{
get => (double)GetValue(IconSizeProperty);
set => SetValue(IconSizeProperty, value);
}
public static readonly DependencyProperty IconSizeProperty = DependencyProperty.Register(
nameof(IconSize),
typeof(double),
typeof(HorizontalIconText),
new PropertyMetadata(14d)
);
public double Spacing
{
get => (double)GetValue(SpacingProperty);
set => SetValue(SpacingProperty, value);
}
public static readonly DependencyProperty SpacingProperty = DependencyProperty.Register(
nameof(Spacing),
typeof(double),
typeof(HorizontalIconText),
new PropertyMetadata(4d)
);
private static void OnOnIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is HorizontalIconText view)
{
view.ShowIcon = view.Icon.IsNotBlank();
}
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ShowSpaceProperty)
{
return;
}
ShowSpace = ShowIcon && Text.IsNotBlank();
}
}
}