From 2ce4f6e24522c21679b751b01c35d5f1b9808091 Mon Sep 17 00:00:00 2001 From: Bunny <1319900154@qq.com> Date: Wed, 8 Jan 2025 18:07:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20WPF=E6=8E=A7=E4=BB=B6-14-PasswordBox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WPF控件-14-PasswordBox/App.xaml | 9 +++++ WPF控件-14-PasswordBox/App.xaml.cs | 12 ++++++ WPF控件-14-PasswordBox/AssemblyInfo.cs | 10 +++++ WPF控件-14-PasswordBox/MainWindow.xaml | 17 +++++++++ WPF控件-14-PasswordBox/MainWindow.xaml.cs | 37 +++++++++++++++++++ .../WPF控件-14-PasswordBox.csproj | 12 ++++++ WPF控件.sln | 6 +++ 7 files changed, 103 insertions(+) create mode 100644 WPF控件-14-PasswordBox/App.xaml create mode 100644 WPF控件-14-PasswordBox/App.xaml.cs create mode 100644 WPF控件-14-PasswordBox/AssemblyInfo.cs create mode 100644 WPF控件-14-PasswordBox/MainWindow.xaml create mode 100644 WPF控件-14-PasswordBox/MainWindow.xaml.cs create mode 100644 WPF控件-14-PasswordBox/WPF控件-14-PasswordBox.csproj diff --git a/WPF控件-14-PasswordBox/App.xaml b/WPF控件-14-PasswordBox/App.xaml new file mode 100644 index 0000000..e278a1e --- /dev/null +++ b/WPF控件-14-PasswordBox/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/WPF控件-14-PasswordBox/App.xaml.cs b/WPF控件-14-PasswordBox/App.xaml.cs new file mode 100644 index 0000000..fd9402f --- /dev/null +++ b/WPF控件-14-PasswordBox/App.xaml.cs @@ -0,0 +1,12 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace WPF控件_14_PasswordBox; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application +{ +} \ No newline at end of file diff --git a/WPF控件-14-PasswordBox/AssemblyInfo.cs b/WPF控件-14-PasswordBox/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/WPF控件-14-PasswordBox/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/WPF控件-14-PasswordBox/MainWindow.xaml b/WPF控件-14-PasswordBox/MainWindow.xaml new file mode 100644 index 0000000..f51ab4c --- /dev/null +++ b/WPF控件-14-PasswordBox/MainWindow.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + \ No newline at end of file diff --git a/WPF控件-14-PasswordBox/MainWindow.xaml.cs b/WPF控件-14-PasswordBox/MainWindow.xaml.cs new file mode 100644 index 0000000..f3a6032 --- /dev/null +++ b/WPF控件-14-PasswordBox/MainWindow.xaml.cs @@ -0,0 +1,37 @@ +using System.Security; +using System.Windows; + +namespace WPF控件_14_PasswordBox; + +/// +/// Interaction logic for MainWindow.xaml +/// +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } + + private void ClearButton_OnClick(object sender, RoutedEventArgs e) + { + PasswordBox.Clear(); + } + + private void PasteButton_OnClick(object sender, RoutedEventArgs e) + { + PasswordBox.Paste(); + } + + private void SelectAllButton_OnClick(object sender, RoutedEventArgs e) + { + PasswordBox.SelectAll(); + var secureString = new SecureString(); + secureString.Dispose(); + } + + private void PasswordBox_OnPasswordChanged(object sender, RoutedEventArgs e) + { + Console.WriteLine(PasswordBox.Password); + } +} \ No newline at end of file diff --git a/WPF控件-14-PasswordBox/WPF控件-14-PasswordBox.csproj b/WPF控件-14-PasswordBox/WPF控件-14-PasswordBox.csproj new file mode 100644 index 0000000..94fc5de --- /dev/null +++ b/WPF控件-14-PasswordBox/WPF控件-14-PasswordBox.csproj @@ -0,0 +1,12 @@ + + + + WinExe + net8.0-windows + WPF控件_14_PasswordBox + enable + enable + true + + + diff --git a/WPF控件.sln b/WPF控件.sln index a502433..d1e2e87 100644 --- a/WPF控件.sln +++ b/WPF控件.sln @@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-12-多文本", "W EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-13-TextBox", "WPF控件-13-TextBox\WPF控件-13-TextBox.csproj", "{C53C3922-EB39-48E7-B88E-7552BDBE839D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-14-PasswordBox", "WPF控件-14-PasswordBox\WPF控件-14-PasswordBox.csproj", "{6371FBC1-A24A-4226-8597-357E50442F07}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -96,5 +98,9 @@ Global {C53C3922-EB39-48E7-B88E-7552BDBE839D}.Debug|Any CPU.Build.0 = Debug|Any CPU {C53C3922-EB39-48E7-B88E-7552BDBE839D}.Release|Any CPU.ActiveCfg = Release|Any CPU {C53C3922-EB39-48E7-B88E-7552BDBE839D}.Release|Any CPU.Build.0 = Release|Any CPU + {6371FBC1-A24A-4226-8597-357E50442F07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6371FBC1-A24A-4226-8597-357E50442F07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6371FBC1-A24A-4226-8597-357E50442F07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6371FBC1-A24A-4226-8597-357E50442F07}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal