diff --git a/Language/zh_CN.xaml b/Language/zh_CN.xaml index 42ce5e4..7c58419 100644 --- a/Language/zh_CN.xaml +++ b/Language/zh_CN.xaml @@ -162,4 +162,14 @@ 保存成功 保存失败 选择路径 + + + 星辉钻石检测系统 + 账号 + 密码 + 记住密码 + 登 录 + 退 出 系 统 + 如果忘记密码,请联系我们 + \ No newline at end of file diff --git a/LoginWindow.xaml b/LoginWindow.xaml new file mode 100644 index 0000000..8bc5b38 --- /dev/null +++ b/LoginWindow.xaml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LoginWindow.xaml.cs b/LoginWindow.xaml.cs new file mode 100644 index 0000000..fe20ed1 --- /dev/null +++ b/LoginWindow.xaml.cs @@ -0,0 +1,31 @@ +using System.Windows; +using System.Windows.Input; + +namespace SparkClient; + +public partial class LoginWindow : Window +{ + public LoginWindow() + { + InitializeComponent(); + WindowStartupLocation = WindowStartupLocation.CenterScreen; + } + private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (e.ButtonState == MouseButtonState.Pressed) + { + this.DragMove(); + } + } + + private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + AccountTextBox.Text = string.Empty; + } + + private void CloseButton_OnClick(object sender, RoutedEventArgs e) + { + this.Close(); + Environment.Exit(0); + } +} \ No newline at end of file diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index a356a83..43de02f 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -13,6 +13,7 @@ using SparkClient.Model.Helper; using SparkClient.ViewModel; using SparkClient.ViewModel.BaseWindow; using SparkClient.Views.BaseWindow; +using MessageBox = SparkClient.Views.Dialog.MessageBox; using Window = System.Windows.Window; namespace SparkClient; @@ -138,9 +139,10 @@ public partial class MainWindow var message = MultilingualHelper.getString("ExitAsk"); var title = MultilingualHelper.getString("ExitAskTitle"); - MessageBoxResult result = HandyControl.Controls.MessageBox.Show( message, title, MessageBoxButton.YesNo, MessageBoxImage.Question ); + // MessageBoxResult result = HandyControl.Controls.MessageBox.Show( message, title, MessageBoxButton.YesNo, MessageBoxImage.Question ); + MessageBoxResult result = new MessageBox().ShowAsk(message); - if (result == MessageBoxResult.Yes) + if (result == MessageBoxResult.OK) { DataBaseHelper.CloseConnection(); // this.Close(); diff --git a/Model/Helper/RegistryHelper.cs b/Model/Helper/RegistryHelper.cs new file mode 100644 index 0000000..116231a --- /dev/null +++ b/Model/Helper/RegistryHelper.cs @@ -0,0 +1,81 @@ +using Microsoft.Win32; + +namespace SparkClient.Model.Helper; + +public static class RegistryHelper +{ + private const string BaseRegistryKey = @"SOFTWARE\Dayu\Spark"; + /// + /// 向注册表写入字符串类型值 + /// + /// 存储的键名 + /// 要写入的字符串值 + public static void WriteString(string keyName, string value) + { + using (var key = Registry.CurrentUser.CreateSubKey(BaseRegistryKey)) + { + key?.SetValue(keyName, value, RegistryValueKind.String); + } + } + + /// + /// 从注册表读取字符串类型值 + /// + /// 存储的键名 + /// 读取到的字符串值,若不存在则返回 null + public static string ReadString(string keyName) + { + using (var key = Registry.CurrentUser.OpenSubKey(BaseRegistryKey)) + { + if (key == null) return null; + return key.GetValue(keyName) as string; + } + } + + /// + /// 向注册表写入布尔类型值(以 0/1 方式) + /// + public static void WriteBool(string keyName, bool value) + { + using (var key = Registry.CurrentUser.CreateSubKey(BaseRegistryKey)) + { + key?.SetValue(keyName, value ? 1 : 0, RegistryValueKind.DWord); + } + } + + /// + /// 从注册表读取布尔类型值(从 0/1 转换) + /// + public static bool ReadBool(string keyName, bool defaultValue = false) + { + using (var key = Registry.CurrentUser.OpenSubKey(BaseRegistryKey)) + { + if (key == null) return defaultValue; + object regValue = key.GetValue(keyName); + if (regValue == null) return defaultValue; + + int intVal; + if (int.TryParse(regValue.ToString(), out intVal)) + { + return intVal != 0; // 1->true, 0->false + } + return defaultValue; + } + } + + /// + /// 删除某个键值 + /// + /// 要删除的键名 + public static void DeleteKey(string keyName) + { + using (var key = Registry.CurrentUser.OpenSubKey(BaseRegistryKey, writable: true)) + { + if (key != null) + { + key.DeleteValue(keyName, throwOnMissingValue: false); + } + } + } + +} \ No newline at end of file diff --git a/Resource/Images/UIResource/08-2.png b/Resource/Images/UIResource/08-2.png new file mode 100644 index 0000000..29f59f3 Binary files /dev/null and b/Resource/Images/UIResource/08-2.png differ diff --git a/Resource/Images/UIResource/08-3.png b/Resource/Images/UIResource/08-3.png new file mode 100644 index 0000000..3ae5da4 Binary files /dev/null and b/Resource/Images/UIResource/08-3.png differ diff --git a/Resource/Images/UIResource/08-4.png b/Resource/Images/UIResource/08-4.png new file mode 100644 index 0000000..234adfc Binary files /dev/null and b/Resource/Images/UIResource/08-4.png differ diff --git a/Resource/Images/UIResource/08-5.jpg b/Resource/Images/UIResource/08-5.jpg new file mode 100644 index 0000000..1345d0b Binary files /dev/null and b/Resource/Images/UIResource/08-5.jpg differ diff --git a/SparkClient.csproj b/SparkClient.csproj index b465070..d8f855a 100644 --- a/SparkClient.csproj +++ b/SparkClient.csproj @@ -154,6 +154,14 @@ + + + + + + + +