Merge branch 'feat-v1' of https://github.com/xiangwork/VideoConcat into feat-v1

This commit is contained in:
xiang 2025-01-11 22:56:10 +08:00
commit 949deef9e4
4 changed files with 110 additions and 17 deletions

View File

@ -0,0 +1,76 @@
// PasswordBoxHelper.cs
using System.Windows;
using System.Windows.Controls;
namespace VideoConcat.Helpers
{
public static class PasswordBoxHelper
{
public static readonly DependencyProperty BoundPasswordProperty =
DependencyProperty.RegisterAttached("BoundPassword", typeof(string), typeof(PasswordBoxHelper),
new PropertyMetadata(string.Empty, OnBoundPasswordChanged));
public static readonly DependencyProperty BindPasswordProperty =
DependencyProperty.RegisterAttached("BindPassword", typeof(bool), typeof(PasswordBoxHelper),
new PropertyMetadata(false, OnBindPasswordChanged));
public static string GetBoundPassword(DependencyObject dp)
{
return (string)dp.GetValue(BoundPasswordProperty);
}
public static void SetBoundPassword(DependencyObject dp, string value)
{
dp.SetValue(BoundPasswordProperty, value);
}
public static bool GetBindPassword(DependencyObject dp)
{
return (bool)dp.GetValue(BindPasswordProperty);
}
public static void SetBindPassword(DependencyObject dp, bool value)
{
dp.SetValue(BindPasswordProperty, value);
}
private static void OnBoundPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is PasswordBox passwordBox)
{
passwordBox.Password = (string)e.NewValue;
}
}
private static void OnBindPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not PasswordBox passwordBox)
{
return;
}
if ((bool)e.OldValue)
{
passwordBox.PasswordChanged -= PasswordChanged;
}
if ((bool)e.NewValue)
{
passwordBox.PasswordChanged += PasswordChanged;
}
}
private static void PasswordChanged(object sender, RoutedEventArgs e)
{
if (sender is PasswordBox passwordBox)
{
var boundPassword = GetBoundPassword(passwordBox);
if (passwordBox.Password != boundPassword)
{
SetBoundPassword(passwordBox, passwordBox.Password);
}
}
}
}
}

View File

@ -4,11 +4,14 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:helpers="clr-namespace:VideoConcat.Helpers"
xmlns:local="clr-namespace:VideoConcat" xmlns:local="clr-namespace:VideoConcat"
mc:Ignorable="d" mc:Ignorable="d"
Title="登录" Height="300" Width="500" Title="登录"
ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Height="300"
> Width="500"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen">
<Window.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
@ -25,11 +28,14 @@
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<StackPanel Width="500"> <StackPanel Width="500">
<StackPanel> <StackPanel>
<TextBlock Margin="20" FontFamily="Great Vibes" <TextBlock Margin="20"
FontSize="38" TextAlignment="Center"> FontFamily="Great Vibes"
FontSize="38"
TextAlignment="Center">
用户登录 用户登录
</TextBlock> </TextBlock>
<StackPanel Margin="10" Orientation="Horizontal"> <StackPanel Margin="10"
Orientation="Horizontal">
<materialDesign:PackIcon <materialDesign:PackIcon
Width="30" Height="30" Width="30" Height="30"
Kind="User" Margin="10,0,10,0"/> Kind="User" Margin="10,0,10,0"/>
@ -39,7 +45,8 @@
SelectionBrush="#FFD94448" SelectionBrush="#FFD94448"
materialDesign:HintAssist.Hint="输入 用户名"/> materialDesign:HintAssist.Hint="输入 用户名"/>
</StackPanel> </StackPanel>
<StackPanel Margin="10" Orientation="Horizontal"> <StackPanel Margin="10"
Orientation="Horizontal">
<materialDesign:PackIcon <materialDesign:PackIcon
Width="30" Height="30" Width="30" Height="30"
Kind="Lock" Margin="10,0,10,0"/> Kind="Lock" Margin="10,0,10,0"/>
@ -49,8 +56,17 @@
CaretBrush="#FFD94448" CaretBrush="#FFD94448"
SelectionBrush="#FFD94448" SelectionBrush="#FFD94448"
materialDesign:HintAssist.Hint="输入 密码" materialDesign:HintAssist.Hint="输入 密码"
x:Name="Password" x:Name="Password"/>
/> <PasswordBox
Width="400"
Margin="10,0"
BorderBrush="White"
CaretBrush="#FFD94448"
SelectionBrush="#FFD94448"
materialDesign:HintAssist.Hint="输入 密码"
helpers:PasswordBoxHelper.BindPassword="True"
helpers:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
</PasswordBox>
</StackPanel> </StackPanel>
<StackPanel Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center">

View File

@ -14,7 +14,7 @@ namespace VideoConcat.Views
private void BtnExit_Click(object sender, RoutedEventArgs e) private void BtnExit_Click(object sender, RoutedEventArgs e)
{ {
this.Close(); Close();
} }
private void BtnLogin_Click(object sender, RoutedEventArgs e) private void BtnLogin_Click(object sender, RoutedEventArgs e)

View File

@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
xmlns:local="clr-namespace:VideoConcat.Views" xmlns:local="clr-namespace:VideoConcat.Views"
mc:Ignorable="d" mc:Ignorable="d"
Title="视频拼接" Height="600" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> Title="视频拼接" Height="600" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">