diff --git a/App.xaml b/App.xaml index 95ef6d0..2afcda8 100644 --- a/App.xaml +++ b/App.xaml @@ -6,6 +6,8 @@ xmlns:baseWindow="clr-namespace:SparkClient.Views.BaseWindow" xmlns:baseWindow1="clr-namespace:SparkClient.ViewModel.BaseWindow" xmlns:views="clr-namespace:SparkClient.Views" + xmlns:configuration="clr-namespace:SparkClient.ViewModel.Configuration" + xmlns:configuration1="clr-namespace:SparkClient.Views.Configuration" StartupUri="MainWindow.xaml"> @@ -28,6 +30,18 @@ + + + + + + + + + + + + diff --git a/Language/zh_CN.xaml b/Language/zh_CN.xaml index a0c766a..c41e720 100644 --- a/Language/zh_CN.xaml +++ b/Language/zh_CN.xaml @@ -20,6 +20,11 @@ 定级配置 切工仪配置 + + 删除配置 + 导入配置 + + 是否退出程序? 是否退出 diff --git a/MainWindow.xaml b/MainWindow.xaml index 7416db7..46e9de5 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -15,10 +15,10 @@ d:DesignWidth="1400" MinHeight="400" MinWidth="800" - WindowState="Maximized" + Loaded="MainWindow_OnLoaded" Background="{DynamicResource SecondaryRegionBrush}"> - + @@ -50,7 +50,9 @@ - + + + @@ -59,7 +61,7 @@ - + @@ -81,7 +83,7 @@ VerticalAlignment="Center" HorizontalAlignment="Center" Margin="20 0 20 0" /> - @@ -94,11 +96,16 @@ - + - + + - + + + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 8946d4d..ea6a3d4 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -3,6 +3,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using HandyControl.Controls; using HandyControl.Tools; using log4net; using log4net.Config; @@ -23,7 +24,7 @@ public partial class MainWindow { InitializeComponent(); - Logger.Info("Application started=================="); + Logger.Info("Application started"); } protected override void OnContentRendered(EventArgs e) @@ -32,14 +33,14 @@ public partial class MainWindow MainViewModel mainVM = new MainViewModel(); DataContext = mainVM; WindowManager.mainViewModel = mainVM; - Logger.Debug("OnContentRendered -------"); + Logger.InfoFormat("窗口加载:"+mainVM.GetType()); } private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { //初始化 - ConfigHelper.Instance.SetLang("en"); + // ConfigHelper.Instance.SetLang("en"); } #region 重写窗体操作按钮 @@ -86,6 +87,23 @@ public partial class MainWindow } } - #endregion + private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (e.LeftButton == MouseButtonState.Pressed) + { + try + { + this.DragMove(); + } + catch (InvalidOperationException ex) + { + + } + } + } + #endregion + + + } \ No newline at end of file diff --git a/Model/Helper/MultilingualHelper.cs b/Model/Helper/MultilingualHelper.cs index b5a93bb..e223a2a 100644 --- a/Model/Helper/MultilingualHelper.cs +++ b/Model/Helper/MultilingualHelper.cs @@ -1,4 +1,5 @@ using System.Windows; +using HandyControl.Tools; namespace SparkClient.Model.Helper; @@ -16,4 +17,50 @@ public class MultilingualHelper } return (string)result; } + + public static void setLanguage(string language) + { + LoadResources(language); + ConfigHelper.Instance.SetLang(language); + } + + private static void LoadResources(string resourceKey) + { + // 获取当前应用程序的App实例 + var app = (App)Application.Current; + + // 根据传入的resourceKey获取对应的资源字典 + var resourceDictionary = app.Resources[resourceKey] as ResourceDictionary; + + if (resourceDictionary!= null) + { + // 获取资源字典的源文件路径(即资源文件的位置) + string requestedCulture = resourceDictionary.Source.OriginalString; + + // 在已合并的资源字典中查找对应的资源字典 + var mergedDictionary = Application.Current.Resources.MergedDictionaries.FirstOrDefault(d => d.Source.OriginalString.Equals(requestedCulture)); + + if (mergedDictionary!= null) + { + // 先移除当前对应的资源字典 + Application.Current.Resources.MergedDictionaries.Remove(mergedDictionary); + + // 再添加回去,以更新资源 + Application.Current.Resources.MergedDictionaries.Add(mergedDictionary); + } + else + { + // 如果未找到对应的资源字典,给出提示信息 + MessageBox.Show($"未找到与 {resourceKey} 对应的资源字典,请检查资源配置。"); + } + } + else + { + // 如果未找到对应的资源字典(根据传入的resourceKey),给出提示信息 + MessageBox.Show($"未找到对应 {resourceKey} 的资源字典,请检查App.xaml中的资源配置。"); + } + + + } + } \ No newline at end of file diff --git a/Resource/Document/Helper.pdf b/Resource/Document/Helper.pdf new file mode 100644 index 0000000..271a04a Binary files /dev/null and b/Resource/Document/Helper.pdf differ diff --git a/Resource/Images/Algor_Def@3x.png b/Resource/Images/Algor_Def@3x.png new file mode 100644 index 0000000..f62a545 Binary files /dev/null and b/Resource/Images/Algor_Def@3x.png differ diff --git a/Resource/Images/Algor_Sel@3x.png b/Resource/Images/Algor_Sel@3x.png new file mode 100644 index 0000000..79b4e62 Binary files /dev/null and b/Resource/Images/Algor_Sel@3x.png differ diff --git a/Resource/Images/Cut_Def@3x.png b/Resource/Images/Cut_Def@3x.png new file mode 100644 index 0000000..4b36580 Binary files /dev/null and b/Resource/Images/Cut_Def@3x.png differ diff --git a/Resource/Images/Cut_Sel@3x.png b/Resource/Images/Cut_Sel@3x.png new file mode 100644 index 0000000..acb1ac8 Binary files /dev/null and b/Resource/Images/Cut_Sel@3x.png differ diff --git a/Resource/Images/Level_Def@3x.png b/Resource/Images/Level_Def@3x.png new file mode 100644 index 0000000..fbb9fbb Binary files /dev/null and b/Resource/Images/Level_Def@3x.png differ diff --git a/Resource/Images/Level_Sel@3x.png b/Resource/Images/Level_Sel@3x.png new file mode 100644 index 0000000..108c4ca Binary files /dev/null and b/Resource/Images/Level_Sel@3x.png differ diff --git a/Resource/Images/diamtest_3x.png b/Resource/Images/diamtest_3x.png new file mode 100644 index 0000000..1e83403 Binary files /dev/null and b/Resource/Images/diamtest_3x.png differ diff --git a/SparkClient.csproj b/SparkClient.csproj index b6fba99..8b02262 100644 --- a/SparkClient.csproj +++ b/SparkClient.csproj @@ -15,6 +15,7 @@ + @@ -35,6 +36,24 @@ + + + + + + + + + + + + + + + + + Always + diff --git a/SparkClient.sln.DotSettings.user b/SparkClient.sln.DotSettings.user index 1df1a09..dfcf03e 100644 --- a/SparkClient.sln.DotSettings.user +++ b/SparkClient.sln.DotSettings.user @@ -1,4 +1,5 @@  + ForceIncluded ForceIncluded ForceIncluded ForceIncluded @@ -6,6 +7,8 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded \ No newline at end of file diff --git a/ViewModel/BaseWindow/BaseControlVM.cs b/ViewModel/BaseWindow/BaseControlVM.cs index 3c2e4f7..d127296 100644 --- a/ViewModel/BaseWindow/BaseControlVM.cs +++ b/ViewModel/BaseWindow/BaseControlVM.cs @@ -22,10 +22,16 @@ public class BaseControlVM : BaseViewModel public object Content { get; } public ICommand CloseCommand { get; } + public BaseControlVM(BaseViewModel vm, string windowTitle) + { + Content = vm; + WindowTitle = windowTitle; + CloseCommand = new RelayCommand(CloseVM); + } + public BaseControlVM(BaseViewModel vm) { Content = vm; - CloseCommand = new RelayCommand(CloseVM); } diff --git a/ViewModel/BaseWindow/HomeWindowVM.cs b/ViewModel/BaseWindow/HomeWindowVM.cs index a97c629..4dfac6c 100644 --- a/ViewModel/BaseWindow/HomeWindowVM.cs +++ b/ViewModel/BaseWindow/HomeWindowVM.cs @@ -2,20 +2,33 @@ using System.Windows.Controls; using System.Windows.Input; using HandyControl.Controls; +using SparkClient.Model.Helper; +using SparkClient.ViewModel.Configuration; + namespace SparkClient.ViewModel.BaseWindow; public class HomeWindowVM : BaseViewModel { public ICommand ShowHelperPageCommand { get; } + + public ICommand ShowConfigPageCommand { get; } public HomeWindowVM() { ShowHelperPageCommand = new RelayCommand(ShowHelperPage); + ShowConfigPageCommand = new RelayCommand(ShowConfigPage); } public void ShowHelperPage(object parameter) { - BaseControlVM vm = new BaseControlVM(new HelperPageVM()); + BaseControlVM vm = new BaseControlVM(new HelperPageVM(), MultilingualHelper.getString("Help")); + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + + public void ShowConfigPage(object parameter) + { + ConfigMenuPageVM vm = new ConfigMenuPageVM(); WindowManager.mainViewModel.Content = vm; WindowManager.openContent.Add(vm); } diff --git a/ViewModel/BaseWindow/MainViewModel.cs b/ViewModel/BaseWindow/MainViewModel.cs index 06ca3d2..f24ceb6 100644 --- a/ViewModel/BaseWindow/MainViewModel.cs +++ b/ViewModel/BaseWindow/MainViewModel.cs @@ -1,3 +1,6 @@ +using System.Windows.Input; +using SparkClient.Model.Helper; + namespace SparkClient.ViewModel.BaseWindow; public class MainViewModel : BaseViewModel @@ -6,9 +9,25 @@ public class MainViewModel : BaseViewModel public object Content { get { return _content; } set { _content = value; OnPropertyChanged("Content"); } } + public ICommand SetZhcnLanguage { get; } + public ICommand SetEnLanguage { get; } + public MainViewModel() { Content = new HomeWindowVM(); WindowManager.openContent.Add(Content); + + SetZhcnLanguage = new RelayCommand(setZhLanguage); + SetEnLanguage = new RelayCommand(setEnLanguage); + } + + public void setZhLanguage(object parameter) + { + MultilingualHelper.setLanguage("zh-cn"); + } + + public void setEnLanguage(object parameter) + { + MultilingualHelper.setLanguage("en"); } } \ No newline at end of file diff --git a/ViewModel/Configuration/AlgorithmConfigVM.cs b/ViewModel/Configuration/AlgorithmConfigVM.cs new file mode 100644 index 0000000..5726ef2 --- /dev/null +++ b/ViewModel/Configuration/AlgorithmConfigVM.cs @@ -0,0 +1,6 @@ +namespace SparkClient.ViewModel.Configuration; + +public class AlgorithmConfigVM : BaseViewModel +{ + +} \ No newline at end of file diff --git a/ViewModel/Configuration/ConfigMenuPageVM.cs b/ViewModel/Configuration/ConfigMenuPageVM.cs new file mode 100644 index 0000000..49f1f2c --- /dev/null +++ b/ViewModel/Configuration/ConfigMenuPageVM.cs @@ -0,0 +1,47 @@ +using System.Windows.Input; +using SparkClient.Model.Helper; +using SparkClient.ViewModel.BaseWindow; + +namespace SparkClient.ViewModel.Configuration; + +public class ConfigMenuPageVM : BaseViewModel +{ + public ICommand CloseCommand { get; } + + public ICommand LevelConfigCommand { get; } + public ICommand AlgorithmConfigCommand { get; } + public ICommand CutConfigCommand { get; } + public ConfigMenuPageVM() + { + CloseCommand = new RelayCommand(CloseVM); + LevelConfigCommand = new RelayCommand(LevelConfig); + AlgorithmConfigCommand = new RelayCommand(AlgorithmConfig); + CutConfigCommand = new RelayCommand(CutConfig); + } + + + public void CloseVM(object parameter) + { + WindowManager.mainViewModel.Content = WindowManager.PreviousVM(); + } + + public void LevelConfig(object parameter) + { + BaseControlVM vm = new BaseControlVM(new LevelConfigVM(), MultilingualHelper.getString("LevelConfig")); + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + public void AlgorithmConfig(object parameter) + { + BaseControlVM vm = new BaseControlVM(new AlgorithmConfigVM(), MultilingualHelper.getString("AlgorithmConfig")); + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + public void CutConfig(object parameter) + { + BaseControlVM vm = new BaseControlVM(new CutConfigVM(), MultilingualHelper.getString("CutConfig")); + WindowManager.mainViewModel.Content = vm; + WindowManager.openContent.Add(vm); + } + +} \ No newline at end of file diff --git a/ViewModel/Configuration/CutConfigVM.cs b/ViewModel/Configuration/CutConfigVM.cs new file mode 100644 index 0000000..923d95a --- /dev/null +++ b/ViewModel/Configuration/CutConfigVM.cs @@ -0,0 +1,6 @@ +namespace SparkClient.ViewModel.Configuration; + +public class CutConfigVM: BaseViewModel +{ + +} \ No newline at end of file diff --git a/ViewModel/Configuration/LevelConfigVM.cs b/ViewModel/Configuration/LevelConfigVM.cs new file mode 100644 index 0000000..885af86 --- /dev/null +++ b/ViewModel/Configuration/LevelConfigVM.cs @@ -0,0 +1,12 @@ +namespace SparkClient.ViewModel.Configuration; + +public class LevelConfigVM: BaseViewModel +{ + + public List _levels; + public List Levels { get { return _levels; } set { _levels = value; OnPropertyChanged("Levels"); } } + public LevelConfigVM() + { + _levels = new List(){"12314", "3455623", "4567894"}; + } +} \ No newline at end of file diff --git a/Views/BaseWindow/HomeWindow.xaml b/Views/BaseWindow/HomeWindow.xaml index 22fb002..38b3b79 100644 --- a/Views/BaseWindow/HomeWindow.xaml +++ b/Views/BaseWindow/HomeWindow.xaml @@ -31,23 +31,28 @@ - @@ -55,30 +60,56 @@ - - - - + + - - - - - - + diff --git a/Views/BaseWindow/HomeWindow.xaml.cs b/Views/BaseWindow/HomeWindow.xaml.cs index 31a3861..74e600b 100644 --- a/Views/BaseWindow/HomeWindow.xaml.cs +++ b/Views/BaseWindow/HomeWindow.xaml.cs @@ -1,4 +1,7 @@ -using System.Windows.Controls; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; using SparkClient.ViewModel.BaseWindow; namespace SparkClient.Views.BaseWindow; @@ -9,4 +12,52 @@ public partial class HomeWindow { InitializeComponent(); } + + private void UIElement_OnMouseLeave(object sender, MouseEventArgs e) + { + if (sender is Border border) + { + var gradientBrush = new RadialGradientBrush(); + + // 设置渐变起始点和中心点 + gradientBrush.GradientOrigin = new Point(0.5, 0.5); // 中心点 + gradientBrush.Center = new Point(0.5, 0.5); + + // 设置渐变半径 + gradientBrush.RadiusX = 0.5; + gradientBrush.RadiusY = 0.5; + + // 添加渐变颜色 + gradientBrush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF4C4D4F"), 0.0)); // 内部颜色 + gradientBrush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF944703"), 2.0)); // 外部颜色 + + // 应用到 Border 的背景 + border.Background = gradientBrush; + //border.Background = new SolidColorBrush(Colors.Transparent); + } + } + + private void UIElement_OnMouseEnter(object sender, MouseEventArgs e) + { + if (sender is Border border) + { + var gradientBrush = new RadialGradientBrush(); + + // 设置渐变起始点和中心点 + gradientBrush.GradientOrigin = new Point(0.5, 0.5); // 中心点 + gradientBrush.Center = new Point(0.5, 0.5); + + // 设置渐变半径 + gradientBrush.RadiusX = 0.5; + gradientBrush.RadiusY = 0.5; + + // 添加渐变颜色 + gradientBrush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF4C4D4F"), 0.0)); // 内部颜色 + gradientBrush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF944703"), 1.0)); // 外部颜色 + + // 应用到 Border 的背景 + border.Background = gradientBrush; + // border.Background = new SolidColorBrush(Color.FromArgb(50, 255, 255, 255)); + } + } } \ No newline at end of file diff --git a/Views/Configuration/ConfigMenuPage.xaml b/Views/Configuration/ConfigMenuPage.xaml index b551c8b..1dbce0e 100644 --- a/Views/Configuration/ConfigMenuPage.xaml +++ b/Views/Configuration/ConfigMenuPage.xaml @@ -5,7 +5,106 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:SparkClient.Views" mc:Ignorable="d" > - - 配置菜单3个 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Views/Configuration/ConfigMenuPage.xaml.cs b/Views/Configuration/ConfigMenuPage.xaml.cs index 9eddfb2..61df299 100644 --- a/Views/Configuration/ConfigMenuPage.xaml.cs +++ b/Views/Configuration/ConfigMenuPage.xaml.cs @@ -1,4 +1,9 @@ -using System.Windows.Controls; +using System.Drawing; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using SparkClient.ViewModel.Configuration; namespace SparkClient.Views.Configuration; @@ -7,5 +12,46 @@ public partial class ConfigMenuPage public ConfigMenuPage() { InitializeComponent(); + DataContext = new ConfigMenuPageVM(); + } + + private void LevelButton_OnMouseEnter(object sender, MouseEventArgs e) + { + var brushConverter = new BrushConverter(); + imgLevel.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Level_Sel@3x.png")); + tbLevel.Foreground = (Brush)brushConverter.ConvertFromString("#9C7C5E");; + } + + private void LevelButton_OnMouseLeave(object sender, MouseEventArgs e) + { + var brushConverter = new BrushConverter(); + imgLevel.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Level_Def@3x.png")); + tbLevel.Foreground = new SolidColorBrush(Colors.Azure); + } + private void AlgorButton_OnMouseEnter(object sender, MouseEventArgs e) + { + var brushConverter = new BrushConverter(); + imgAlgor.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Algor_Sel@3x.png")); + tbAlgor.Foreground = (Brush)brushConverter.ConvertFromString("#9C7C5E");; + } + + private void AlgorButton_OnMouseLeave(object sender, MouseEventArgs e) + { + var brushConverter = new BrushConverter(); + imgAlgor.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Algor_Def@3x.png")); + tbAlgor.Foreground = new SolidColorBrush(Colors.Azure); + } + private void CutButton_OnMouseEnter(object sender, MouseEventArgs e) + { + var brushConverter = new BrushConverter(); + imgCut.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Cut_Sel@3x.png")); + tbCut.Foreground = (Brush)brushConverter.ConvertFromString("#9C7C5E");; + } + + private void CutButton_OnMouseLeave(object sender, MouseEventArgs e) + { + var brushConverter = new BrushConverter(); + imgCut.Source = new BitmapImage(new Uri(@"pack://application:,,,/Resource/Images/Cut_Def@3x.png")); + tbCut.Foreground = new SolidColorBrush(Colors.Azure); } } \ No newline at end of file diff --git a/Views/Configuration/LevelConfigPage.xaml b/Views/Configuration/LevelConfigPage.xaml index d61722c..fc7f594 100644 --- a/Views/Configuration/LevelConfigPage.xaml +++ b/Views/Configuration/LevelConfigPage.xaml @@ -4,8 +4,31 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:SparkClient.Views" + xmlns:hc="https://handyorg.github.io/handycontrol" mc:Ignorable="d" > - - 定级配置 + + + + + + + + + + + + + + + +