diff --git a/.htm b/.htm
new file mode 100644
index 0000000..49b891c
--- /dev/null
+++ b/.htm
@@ -0,0 +1,269 @@
+
+
+
+ 迁移报告
+
+ 迁移报告 -
概述
解决方案和项目
Setup
| ..\Setup\Setup.vdproj:
+ 找不到此项目类型所基于的应用程序。有关更多信息,请尝试此链接: 54435603-dbb4-11d2-8724-00a0c9a8b90c |
VideoConcat
\ No newline at end of file
diff --git a/Helpers/PasswordBoxHelper.cs b/Helpers/PasswordBoxHelper.cs
new file mode 100644
index 0000000..dcffdec
--- /dev/null
+++ b/Helpers/PasswordBoxHelper.cs
@@ -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);
+ }
+
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Models/MainWindowModel.cs b/Models/MainWindowModel.cs
index 634fe0a..bca9b16 100644
--- a/Models/MainWindowModel.cs
+++ b/Models/MainWindowModel.cs
@@ -1,12 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace VideoConcat.Models
+namespace VideoConcat.Models
{
- internal class MainWindowModel
+ public class MainWindowModel
{
public string? Username { get; set; }
public string? Password { get; set; }
diff --git a/VideoConcat.csproj b/VideoConcat.csproj
index b83112c..111d1c6 100644
--- a/VideoConcat.csproj
+++ b/VideoConcat.csproj
@@ -11,9 +11,9 @@
-
+
-
+
diff --git a/VideoConcat.sln b/VideoConcat.sln
index 6f6e4ad..5093c67 100644
--- a/VideoConcat.sln
+++ b/VideoConcat.sln
@@ -5,8 +5,6 @@ VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VideoConcat", "VideoConcat.csproj", "{2FF5691C-3184-4B68-944B-C704E64C4E4E}"
EndProject
-Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "..\Setup\Setup.vdproj", "{7EE4FDA6-076F-494D-89C5-B3735A89875F}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -17,8 +15,6 @@ Global
{2FF5691C-3184-4B68-944B-C704E64C4E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FF5691C-3184-4B68-944B-C704E64C4E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FF5691C-3184-4B68-944B-C704E64C4E4E}.Release|Any CPU.Build.0 = Release|Any CPU
- {7EE4FDA6-076F-494D-89C5-B3735A89875F}.Debug|Any CPU.ActiveCfg = Debug
- {7EE4FDA6-076F-494D-89C5-B3735A89875F}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs
index b278c5a..457900d 100644
--- a/ViewModels/MainWindowViewModel.cs
+++ b/ViewModels/MainWindowViewModel.cs
@@ -1,30 +1,45 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Windows;
+using VideoConcat.Models;
namespace VideoConcat.ViewModels
{
public partial class MainWindowViewModel : ObservableObject
{
- private string? _username;
- private string? _password;
+ private readonly MainWindowModel _mainWindow = new();
public string Username
{
- get => _username ?? "";
- set => SetProperty(ref _username, value);
+ get => _mainWindow.Username ?? "";
+ set
+ {
+ if (_mainWindow.Username != value)
+ {
+ _mainWindow.Username = value;
+ OnPropertyChanged(nameof(Username));
+ }
+ }
}
public string Password
{
- get => _password ?? "";
- set => SetProperty(ref _password, value);
+ get => _mainWindow.Password ?? "";
+ set
+ {
+ if (_mainWindow.Password != value)
+ {
+ _mainWindow.Password = value;
+
+ }
+
+ }
}
[RelayCommand]
- private async Task LoginAsync()
+ private void Login()
{
- await Task.Run(() =>
+ if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
{
// 模拟登录逻辑
if (Username == "admin" && Password == "password")
@@ -36,7 +51,12 @@ namespace VideoConcat.ViewModels
{
MessageBox.Show("用户名或密码错误!");
}
- });
+ }
+ else
+ {
+ MessageBox.Show("请输入用户名或密码!");
+ }
+
}
}
}
diff --git a/Views/MainWindow.xaml b/Views/MainWindow.xaml
index 06cae17..7446540 100644
--- a/Views/MainWindow.xaml
+++ b/Views/MainWindow.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:helpers="clr-namespace:VideoConcat.Helpers"
xmlns:local="clr-namespace:VideoConcat"
mc:Ignorable="d"
Title="登录"
@@ -40,7 +41,7 @@
Height="30"
Kind="User"
Margin="10,0,10,0"/>
-
+ helpers:PasswordBoxHelper.BindPassword="True"
+ helpers:PasswordBoxHelper.BoundPassword="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
+
+
+ Command="{Binding LoginCommand}"/>
diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs
index 9d0e5d5..0b41bb8 100644
--- a/Views/MainWindow.xaml.cs
+++ b/Views/MainWindow.xaml.cs
@@ -1,6 +1,5 @@
using System.Windows;
-using System.Windows.Input;
-using VideoConcat.Models;
+using VideoConcat.ViewModels;
namespace VideoConcat.Views
{
@@ -12,7 +11,7 @@ namespace VideoConcat.Views
public MainWindow()
{
InitializeComponent();
- DataContext = new MainWindowModel();
+ DataContext = new MainWindowViewModel();
}
private void BtnExit_Click(object sender, RoutedEventArgs e)