diff --git a/Constant/Constants.cs b/Constant/Constants.cs index 3eb6edb..544262d 100644 --- a/Constant/Constants.cs +++ b/Constant/Constants.cs @@ -13,6 +13,7 @@ namespace GeekDesk.Constant public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk"; + /// /// app数据文件路径 /// @@ -21,11 +22,13 @@ namespace GeekDesk.Constant /// /// 备份文件路径 /// - public static string DATA_FILE_BAK_PATH = APP_DIR + "bak\\Data.bak"; //app数据文件路径 + public static string DATA_FILE_BAK_PATH = APP_DIR + "bak\\Data.bak"; //app备份数据文件路径 - public static string LOG_FILE_PATH = APP_DIR + "logs\\log.log"; + public static string PW_FILE_BAK_PATH = APP_DIR + "bak\\pw.txt"; //密码文件路径 - public static string ERROR_FILE_PATH = APP_DIR + "logs\\error.log"; + public static string LOG_FILE_PATH = APP_DIR + "logs\\log.log"; //日志文件 + + public static string ERROR_FILE_PATH = APP_DIR + "logs\\error.log"; // 错误日志 public static int SHADOW_WIDTH = 20; diff --git a/Constant/PasswordType.cs b/Constant/PasswordType.cs new file mode 100644 index 0000000..3c97bc8 --- /dev/null +++ b/Constant/PasswordType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekDesk.Constant +{ + public enum PasswordType + { + INPUT = 0, //键入密码 + CREATE = 1, //新建密码 + ALTER = 2, //修改密码 + CANCEL = 3, //取消密码 + } +} diff --git a/Constant/RunTimeStatus.cs b/Constant/RunTimeStatus.cs index ba82f5a..8570c7d 100644 --- a/Constant/RunTimeStatus.cs +++ b/Constant/RunTimeStatus.cs @@ -20,7 +20,20 @@ public static bool LOCK_APP_PANEL = false; + /// + /// 是否弹出了菜单密码框 + /// + public static bool SHOW_MENU_PASSWORDBOX = false; + /// + /// 是否弹出了右键菜单 + /// + public static bool SHOW_RIGHT_BTN_MENU = false; + + /// + /// 是否正在编辑菜单 + /// + public static bool IS_MENU_EDIT = false; } } diff --git a/Control/Other/PasswordDialog.xaml b/Control/Other/PasswordDialog.xaml new file mode 100644 index 0000000..39dca05 --- /dev/null +++ b/Control/Other/PasswordDialog.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Control/Other/PasswordDialog.xaml.cs b/Control/Other/PasswordDialog.xaml.cs new file mode 100644 index 0000000..c6139ac --- /dev/null +++ b/Control/Other/PasswordDialog.xaml.cs @@ -0,0 +1,280 @@ +using GeekDesk.Constant; +using GeekDesk.Util; +using GeekDesk.ViewModel; +using Microsoft.Win32; +using System; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media.Imaging; +using System.Windows.Threading; + +namespace GeekDesk.Control.Other +{ + /// + /// TextDialog.xaml 的交互逻辑 + /// + public partial class PasswordDialog + { + private AppData appData = MainWindow.appData; + + public PasswordType type; + public MenuInfo menuInfo; + public int count = 0; + private string tempPassword = null; + private PasswordType tempType; + public PasswordDialog() + { + InitializeComponent(); + } + private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) + { + PasswordBox pb = sender as PasswordBox; + if (!string.IsNullOrEmpty(pb.Password)) + { + char c = pb.Password.ToCharArray()[0]; + if (c > '9' || c < '0') + { + pb.Password = ""; + return; + } + } + string tag = pb.Tag.ToString(); + switch (tag) + { + case "P1": + if (!string.IsNullOrEmpty(pb.Password)) + { + P2.Focus(); + } + break; + case "P2": + if (!string.IsNullOrEmpty(pb.Password)) + { + P3.Focus(); + } + break; + case "P3": + if (!string.IsNullOrEmpty(pb.Password)) + { + P4.Focus(); + } + break; + case "P4": + if (string.IsNullOrEmpty(pb.Password)) + { + P3.Focus(); + } + break; + } + + if (!string.IsNullOrEmpty(P1.Password) + && !string.IsNullOrEmpty(P2.Password) + && !string.IsNullOrEmpty(P3.Password) + && !string.IsNullOrEmpty(P4.Password)) + { + string pw = P1.Password + + P2.Password + + P3.Password + + P4.Password; + pw = MD5Util.CreateMD5(pw); + if (type == PasswordType.INPUT || type == PasswordType.CANCEL) + { + if (pw.Equals(appData.AppConfig.MenuPassword)) + { + //隐藏弹框 + MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed; + //赋值 + MainWindow.appData.AppConfig.SelectedMenuIcons + = appData.MenuList[ + MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex + ].IconList; + //显示数据托盘 + MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible; + //取消加密操作 + if (type == PasswordType.CANCEL) + { + menuInfo.IsEncrypt = false; + } + } else + { + //密码比对不一致 + ErrorMsg.Text = "密码输入错误"; + ErrorMsg.Visibility = Visibility.Visible; + if (!string.IsNullOrEmpty(appData.AppConfig.PasswordHint)) + { + //显示提示信息 + HintMsg.Visibility = Visibility.Visible; + } + } + } else if (type == PasswordType.CREATE) + { + //创建密码 + if (count == 0) + { + count++; + tempPassword = pw; + Title.Text = "再次输入密码"; + ClearVal(); + SetFocus(0); + } else + { + if (tempPassword.Equals(pw)) + { + //两次密码设置一致 显示提示输入框 + Title.Text = "填写密码提示"; + PasswordGrid.Visibility = Visibility.Collapsed; + HintGrid.Visibility = Visibility.Visible; + HintBox.Focus(); + } else + { + ErrorMsg.Text = "两次密码输入不一致"; + ErrorMsg.Visibility = Visibility.Visible; + } + } + } else if (type == PasswordType.ALTER) + { + //修改密码 + if (appData.AppConfig.MenuPassword.Equals(pw)) + { + tempType = type; + type = PasswordType.CREATE; + Title.Text = "设置新密码"; + ClearVal(); + SetFocus(0); + } else + { + //密码比对不一致 + ErrorMsg.Text = "密码输入错误"; + ErrorMsg.Visibility = Visibility.Visible; + HintMsg.Text = MainWindow.appData.AppConfig.PasswordHint; + HintMsg.Visibility = Visibility.Visible; + } + } + } else + { + //密码未输入完全 隐藏错误信息 + if (ErrorMsg.IsVisible) + { + ErrorMsg.Visibility = Visibility.Hidden; + HintMsg.Visibility = Visibility.Hidden; + HintMsg.Visibility = Visibility.Hidden; + } + } + } + + public void SetFocus(int time = 100) + { + new Thread(() => + { + Thread.Sleep(time); + Dispatcher.Invoke(() => + { + if (string.IsNullOrEmpty(P1.Password)) + { + P1.Focus(); + return; + } + if (string.IsNullOrEmpty(P2.Password)) + { + P2.Focus(); + return; + } + if (string.IsNullOrEmpty(P3.Password)) + { + P3.Focus(); + return; + } + P4.Focus(); + }); + }).Start(); + } + + public void ClearVal() + { + P1.Clear(); + P2.Clear(); + P3.Clear(); + P4.Clear(); + } + + /// + /// 跳过设置密码提示 + /// + /// + /// + private void NextTB_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + appData.AppConfig.PasswordHint = ""; + DonePassword(); + } + + private void DoneTB_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + string hint = HintBox.Text.Trim(); + appData.AppConfig.PasswordHint = hint; + DonePassword(); + } + + private void DonePassword() + { + appData.AppConfig.MenuPassword = tempPassword; + CommonCode.SavePassword(tempPassword); + MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed; + PasswordGrid.Visibility = Visibility.Visible; + HintGrid.Visibility = Visibility.Collapsed; + if (tempType == PasswordType.ALTER) + { + HandyControl.Controls.Growl.Success("密码修改成功!", "MainWindowGrowl"); + } else + { + menuInfo.IsEncrypt = true; + HandyControl.Controls.Growl.Success(menuInfo.MenuName + " 已加密!", "MainWindowGrowl"); + } + + } + + private void PasswordBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Back) + { + if (P2.IsKeyboardFocused) + { + if (string.IsNullOrEmpty(P2.Password)) + { + P1.Password = ""; + } else + { + P2.Password = ""; + } + } + + if (P3.IsKeyboardFocused) + { + if (string.IsNullOrEmpty(P3.Password)) + { + P2.Password = ""; + } + else + { + P3.Password = ""; + } + } + + if (P4.IsKeyboardFocused) + { + if (string.IsNullOrEmpty(P4.Password)) + { + P3.Password = ""; + } + else + { + P4.Password = ""; + } + } + } + SetFocus(0); + } + } +} diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml b/Control/UserControls/PannelCard/LeftCardControl.xaml index d78eb55..4d2a4df 100644 --- a/Control/UserControls/PannelCard/LeftCardControl.xaml +++ b/Control/UserControls/PannelCard/LeftCardControl.xaml @@ -30,6 +30,7 @@ + @@ -121,11 +122,12 @@ + BorderThickness="1" + Effect="{DynamicResource EffectShadow2}" + Margin="5,0,0,5" + MouseDown="MyCard_MouseDown" + PreviewMouseRightButtonDown="MyCard_PreviewMouseRightButtonDown" + > @@ -137,28 +139,28 @@ + - - - - + Padding="2,3,0,2" + ItemsSource="{Binding MenuList}" + Tag="{Binding AppConfig.MenuCardWidth}" + BorderThickness="0" Foreground="{x:Null}" + SelectedIndex="{Binding AppConfig.SelectedMenuIndex}" + VirtualizingPanel.VirtualizationMode="Recycling" + SelectionChanged="Menu_SelectionChanged" + PreviewMouseWheel="Menu_MouseWheel" + PreviewMouseRightButtonDown="MyCard_PreviewMouseRightButtonDown" + > + + @@ -181,8 +183,7 @@ - + private void RenameMenu(object sender, RoutedEventArgs e) { - IS_EDIT = true; + RunTimeStatus.IS_MENU_EDIT = true; MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo; menuInfo.MenuEdit = (int)Visibility.Visible; } @@ -275,7 +273,7 @@ namespace GeekDesk.Control.UserControls.PannelCard menuInfo.MenuName = text; menuInfo.MenuEdit = Visibility.Collapsed; } - IS_EDIT = false; + RunTimeStatus.IS_MENU_EDIT = false; //为了解决无法修改菜单的问题 MainWindow.mainWindow.SearchBox.Focus(); MenuListBox.SelectedIndex = menuSelectIndexTemp; @@ -311,7 +309,7 @@ namespace GeekDesk.Control.UserControls.PannelCard private void Menu_SelectionChanged(object sender, SelectionChangedEventArgs e) { - if (IS_EDIT) return; + if (RunTimeStatus.IS_MENU_EDIT) return; MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Collapsed; @@ -322,7 +320,18 @@ namespace GeekDesk.Control.UserControls.PannelCard } else { - appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList; + if (appData.MenuList[MenuListBox.SelectedIndex].IsEncrypt) + { + appData.AppConfig.SelectedMenuIcons = null; + RunTimeStatus.SHOW_MENU_PASSWORDBOX = true; + MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入密码"; + MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible; + } + else + { + MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Collapsed; + appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList; + } } MainWindow.mainWindow.RightCard.WrapUFG.Visibility = Visibility.Visible; } @@ -335,7 +344,7 @@ namespace GeekDesk.Control.UserControls.PannelCard /// private void Menu_MouseEnter(object sender, MouseEventArgs e) { - if (appData.AppConfig.HoverMenu && !IS_EDIT) + if (appData.AppConfig.HoverMenu && !RunTimeStatus.IS_MENU_EDIT) { Thread t = new Thread(() => { @@ -406,6 +415,7 @@ namespace GeekDesk.Control.UserControls.PannelCard private void Menu_MouseWheel(object sender, MouseWheelEventArgs e) { + if (RunTimeStatus.IS_MENU_EDIT) return; if (e.Delta < 0) { int index = MenuListBox.SelectedIndex; @@ -461,5 +471,104 @@ namespace GeekDesk.Control.UserControls.PannelCard appData.MenuList[MenuListBox.SelectedIndex].IconList.Remove(iconInfo); appData.MenuList[MenuListBox.Items.IndexOf(mi)].IconList.Add(iconInfo); } + + private void EncryptMenu(object sender, RoutedEventArgs e) + { + MenuInfo menuInfo = ((MenuItem)sender).Tag as MenuInfo; + if (menuInfo.IsEncrypt) + { + MainWindow.mainWindow.RightCard.PDDialog.menuInfo = menuInfo; + MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入密码"; + MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.CANCEL; + RunTimeStatus.SHOW_MENU_PASSWORDBOX = true; + MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible; + //单独设置焦点 + MainWindow.mainWindow.RightCard.PDDialog.SetFocus(); + } else + { + if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword)) + { + MainWindow.mainWindow.RightCard.PDDialog.menuInfo = menuInfo; + MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "设置新密码"; + MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.CREATE; + RunTimeStatus.SHOW_MENU_PASSWORDBOX = true; + MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible; + } + else + { + menuInfo.IsEncrypt = true; + HandyControl.Controls.Growl.Success(menuInfo.MenuName + " 已加密!", "MainWindowGrowl"); + } + } + } + + private void AlterPassword(object sender, RoutedEventArgs e) + { + MainWindow.mainWindow.RightCard.PDDialog.Title.Text = "输入旧密码"; + MainWindow.mainWindow.RightCard.PDDialog.type = PasswordType.ALTER; + MainWindow.mainWindow.RightCard.PDDialog.Visibility = Visibility.Visible; + //单独设置焦点 + MainWindow.mainWindow.RightCard.PDDialog.SetFocus(); + } + + /// + /// 右键点击进行处理 + /// + /// + /// + private void MyCard_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) + { + RunTimeStatus.SHOW_RIGHT_BTN_MENU = true; + new Thread(() => + { + Thread.Sleep(50); + RunTimeStatus.SHOW_RIGHT_BTN_MENU = false; + }).Start(); + + //在没有设置密码的情况下不弹出修改密码菜单 + if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword)) + { + AlterPW1.Visibility = Visibility.Collapsed; + } else + { + AlterPW1.Visibility = Visibility.Visible; + } + } + + private void ListBoxItem_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) + { + ListBoxItem lbi = sender as ListBoxItem; + MenuInfo info = lbi.DataContext as MenuInfo; + + ItemCollection ics = lbi.ContextMenu.Items; + + foreach (object obj in ics) + { + MenuItem mi = (MenuItem)obj; + if (mi.Header.Equals("修改密码")) + { + if (string.IsNullOrEmpty(appData.AppConfig.MenuPassword)) + { + mi.Visibility = Visibility.Collapsed; + } + else + { + mi.Visibility = Visibility.Visible; + } + break; + } + if (mi.Header.Equals("加密此列表") || mi.Header.Equals("取消加密此列表")) + { + if (info.IsEncrypt) + { + mi.Header = "取消加密此列表"; + } else + { + mi.Header = "加密此列表"; + } + } + } + + } } } diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml b/Control/UserControls/PannelCard/RightCardControl.xaml index ef0637a..827d7c4 100644 --- a/Control/UserControls/PannelCard/RightCardControl.xaml +++ b/Control/UserControls/PannelCard/RightCardControl.xaml @@ -8,6 +8,7 @@ xmlns:cvt="clr-namespace:GeekDesk.Converts" xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel" xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF" + xmlns:ot="clr-namespace:GeekDesk.Control.Other" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" > @@ -93,7 +94,9 @@ BorderThickness="1" Effect="{DynamicResource EffectShadow2}" Margin="5,0,5,5" Grid.ColumnSpan="2" - PreviewMouseRightButtonDown="WrapCard_PreviewMouseRightButtonDown"> + PreviewMouseRightButtonDown="WrapCard_PreviewMouseRightButtonDown" + hc:Dialog.Token="RightWrapCardDialog" + > @@ -107,29 +110,36 @@ - - - - - + + + + + + + + ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=OneWay}" + BorderThickness="0" + Padding="0,10,0,0" + > + ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelWidth, Mode=OneWay}" + ItemsHeight="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=DataContext.AppConfig.ImgPanelHeight, Mode=OneWay}" + HorizontalAlignment="Center" + SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>--> @@ -154,46 +164,46 @@ - - - - - - - + + + + + + + - - - - - + + + + + @@ -797,5 +798,25 @@ namespace GeekDesk.Control.UserControls.PannelCard { SearchListBox.ScrollIntoView(SearchListBox.SelectedItem); } + + private void PDDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (PDDialog.Visibility == Visibility.Visible) + { + RunTimeStatus.SHOW_MENU_PASSWORDBOX = true; + PDDialog.ClearVal(); + PDDialog.ErrorMsg.Visibility = Visibility.Collapsed; + PDDialog.PasswordGrid.Visibility = Visibility.Visible; + PDDialog.HintGrid.Visibility = Visibility.Collapsed; + PDDialog.count = 0; + PDDialog.SetFocus(); + } + else + { + RunTimeStatus.SHOW_MENU_PASSWORDBOX = false; + PDDialog.ClearVal(); + MainWindow.mainWindow.Focus(); + } + } } } diff --git a/GeekDesk.csproj b/GeekDesk.csproj index 37c64fa..6fb53bd 100644 --- a/GeekDesk.csproj +++ b/GeekDesk.csproj @@ -161,6 +161,7 @@ + @@ -179,6 +180,9 @@ GradientBGDialog.xaml + + PasswordDialog.xaml + MyColorPickerDialog.xaml @@ -278,6 +282,7 @@ + @@ -310,6 +315,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -506,7 +515,7 @@ - + diff --git a/MainWindow.xaml b/MainWindow.xaml index 358317b..833185e 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -55,7 +55,7 @@ BorderThickness="0" Focusable="True" x:Name="BGBorder" - hc:Dialog.Token="IconInfoDialog" + hc:Dialog.Token="MainWindowDialog" > - - - diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 392a8aa..abdafbe 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -435,6 +435,7 @@ namespace GeekDesk //} MainWindow.mainWindow.Activate(); + mainWindow.Visibility = Visibility.Visible; if (MarginHide.ON_HIDE) { @@ -454,7 +455,13 @@ namespace GeekDesk FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible); Keyboard.Focus(mainWindow); - Keyboard.Focus(mainWindow.SearchBox); + if (RunTimeStatus.SHOW_MENU_PASSWORDBOX) + { + mainWindow.RightCard.PDDialog.SetFocus(); + } else + { + Keyboard.Focus(mainWindow.SearchBox); + } } public static void HideApp() @@ -742,14 +749,25 @@ namespace GeekDesk GlobalColorPickerWindow.CreateNoShow(); } - private void Window_GotFocus(object sender, RoutedEventArgs e) { - if (!LeftCard.IS_EDIT) + // 如果没有在修改菜单 并且不是右键点击了面板 + if (!RunTimeStatus.IS_MENU_EDIT + && !RunTimeStatus.SHOW_RIGHT_BTN_MENU) { - //if判断是为了能够使修改菜单时 菜单能够获得焦点 - Keyboard.Focus(SearchBox); + if (RunTimeStatus.SHOW_MENU_PASSWORDBOX) + { + //必须在其它文本框没有工作的时候才给密码框焦点 + RightCard.PDDialog.SetFocus(); + } + else + { + //必须在其它文本框没有工作的时候才给搜索框焦点 + Keyboard.Focus(SearchBox); + } + } + } private void AppWindow_Deactivated(object sender, EventArgs e) diff --git a/Util/CommonCode.cs b/Util/CommonCode.cs index 889b787..040ff82 100644 --- a/Util/CommonCode.cs +++ b/Util/CommonCode.cs @@ -97,7 +97,10 @@ namespace GeekDesk.Util { lock (_MyLock) { - appData.AppConfig.SysBakTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + if (filePath.Equals(Constants.DATA_FILE_BAK_PATH)) + { + appData.AppConfig.SysBakTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } if (!Directory.Exists(filePath.Substring(0, filePath.LastIndexOf("\\")))) { Directory.CreateDirectory(filePath.Substring(0, filePath.LastIndexOf("\\"))); @@ -108,9 +111,18 @@ namespace GeekDesk.Util bf.Serialize(fs, appData); } } - } + + public static void SavePassword(string password) + { + using (StreamWriter sw = new StreamWriter(Constants.PW_FILE_BAK_PATH)) + { + sw.Write(password); + } + } + + public static void BakAppData() { diff --git a/Util/MD5Util.cs b/Util/MD5Util.cs new file mode 100644 index 0000000..de9df9b --- /dev/null +++ b/Util/MD5Util.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekDesk.Util +{ + internal class MD5Util + { + + public static string CreateMD5(string input) + { + // Use input string to calculate MD5 hash + using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create()) + { + byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input); + byte[] hashBytes = md5.ComputeHash(inputBytes); + + //return Convert.ToHexString(hashBytes); // .NET 5 + + + //Convert the byte array to hexadecimal string prior to.NET 5 + StringBuilder sb = new System.Text.StringBuilder(); + for (int i = 0; i < hashBytes.Length; i++) + { + sb.Append(hashBytes[i].ToString("X2")); + } + return sb.ToString(); + } + } + } +} diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs index ab94dfd..217b06b 100644 --- a/ViewModel/AppConfig.cs +++ b/ViewModel/AppConfig.cs @@ -95,8 +95,36 @@ namespace GeekDesk.ViewModel private string sysBakTime; //系统自动备份时间 + private string menuPassword; //锁菜单密码 + + private string passwordHint; //密码提示 #region GetSet + public string PasswordHint + { + get + { + return passwordHint; + } + set + { + passwordHint = value; + OnPropertyChanged("PasswordHint"); + } + } + public string MenuPassword + { + get + { + return menuPassword; + } + set + { + menuPassword = value; + OnPropertyChanged("MenuPassword"); + } + } + public string SysBakTime { get diff --git a/ViewModel/MenuInfo.cs b/ViewModel/MenuInfo.cs index 72a16b9..243604b 100644 --- a/ViewModel/MenuInfo.cs +++ b/ViewModel/MenuInfo.cs @@ -20,8 +20,22 @@ namespace GeekDesk.ViewModel private string menuGeometry; //菜单几何图标 private string geometryColor; //几何图标颜色 private ObservableCollection iconList = new ObservableCollection(); + private bool isEncrypt; //是否加密 + public bool IsEncrypt + { + get + { + return isEncrypt; + } + set + { + isEncrypt = value; + OnPropertyChanged("IsEncrypt"); + } + } + public string MenuGeometry { get