添加项目文件。

This commit is contained in:
czj
2026-06-05 10:57:09 +08:00
parent f29671b374
commit d960cb5912
166 changed files with 15996 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace UIShare.Helpers
{
public static class PasswordBoxHelper
{
public static readonly DependencyProperty PasswordProperty =
DependencyProperty.RegisterAttached(
"Password",
typeof(string),
typeof(PasswordBoxHelper),
new FrameworkPropertyMetadata(
string.Empty,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
OnPasswordPropertyChanged));
public static void SetPassword(DependencyObject d, string value)
=> d.SetValue(PasswordProperty, value);
public static string GetPassword(DependencyObject d)
=> (string)d.GetValue(PasswordProperty);
private static void OnPasswordPropertyChanged(
DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
if (d is PasswordBox pb)
{
pb.PasswordChanged -= PasswordChanged;
if (pb.Password != (string)e.NewValue)
{
pb.Password = (string)e.NewValue;
}
pb.PasswordChanged += PasswordChanged;
}
}
private static void PasswordChanged(object sender, RoutedEventArgs e)
{
if (sender is PasswordBox pb)
{
SetPassword(pb, pb.Password);
}
}
}
}

View File

@@ -0,0 +1,41 @@
using System.Windows;
using System.Windows.Input;
namespace UIShare.Helpers
{
public static class WindowDragHelper
{
public static readonly DependencyProperty EnableWindowDragProperty =
DependencyProperty.RegisterAttached(
"EnableWindowDrag",
typeof(bool),
typeof(WindowDragHelper),
new PropertyMetadata(false, OnEnableWindowDragChanged));
public static bool GetEnableWindowDrag(DependencyObject obj) =>
(bool)obj.GetValue(EnableWindowDragProperty);
public static void SetEnableWindowDrag(DependencyObject obj, bool value) =>
obj.SetValue(EnableWindowDragProperty, value);
private static void OnEnableWindowDragChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is FrameworkElement element)
{
if ((bool)e.NewValue)
element.MouseLeftButtonDown += Element_MouseLeftButtonDown;
else
element.MouseLeftButtonDown -= Element_MouseLeftButtonDown;
}
}
private static void Element_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender is FrameworkElement element)
{
var window = Window.GetWindow(element);
window?.DragMove();
}
}
}
}