96 lines
3.4 KiB
96 lines
3.4 KiB
using System.Windows; |
|
using System.Windows.Input; |
|
using log4net; |
|
using SparkClient.Model.Helper; |
|
using SparkClient.Model.Services; |
|
using SparkClient.ViewModel.Configuration; |
|
using SparkClient.ViewModel.Grading; |
|
using MessageBox = SparkClient.Views.Dialog.MessageBox; |
|
|
|
namespace SparkClient.ViewModel.BaseWindow; |
|
|
|
public class HomeWindowVM : BaseViewModel |
|
{ |
|
private static readonly ILog Logger = LogManager.GetLogger(typeof(HomeWindowVM)); |
|
private SOCClientService _socClientService; |
|
public ICommand ShowHelperPageCommand { get; } |
|
|
|
public ICommand ShowConfigPageCommand { get; } |
|
public ICommand ShowDiamondSelPageCommand { get; } |
|
|
|
public HomeWindowVM() |
|
{ |
|
ShowHelperPageCommand = new RelayCommand(ShowHelperPage); |
|
ShowConfigPageCommand = new RelayCommand(ShowConfigPage); |
|
ShowDiamondSelPageCommand = new RelayCommand(ShowDiamlondSelPage); |
|
} |
|
|
|
public void ShowHelperPage(object parameter) |
|
{ |
|
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); |
|
} |
|
|
|
public async void ShowDiamlondSelPage(object parameter) |
|
{ |
|
try |
|
{ |
|
// string savePath = @"..\..\..\Resource\SOCImages"; |
|
// string result = await _socClientService.ProcessImageCollectionAsync(100, savePath); |
|
// |
|
// ShowMessage(result); |
|
// |
|
// if (result == "成功") |
|
// { |
|
// BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult")); |
|
// WindowManager.mainViewModel.Content = vm; |
|
// WindowManager.openContent.Add(vm); |
|
// } |
|
//BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult")); |
|
//WindowManager.mainViewModel.Content = vm; |
|
//WindowManager.openContent.Add(vm); |
|
|
|
//MessageBox messageBox = new MessageBox(); |
|
//MessageBoxResult result = messageBox.ShowInput(MultilingualHelper.getString("UpdateDiamondCode"),out string inputStr, |
|
// MultilingualHelper.getString("ok"), |
|
// MultilingualHelper.getString("Skip") |
|
// ); |
|
//if (result != MessageBoxResult.None) |
|
//{ |
|
BaseControlVM vm = new BaseControlVM(new DiamondSelectVM(), MultilingualHelper.getString("DiamondSelect")); |
|
vm.ShowFunctionButton = System.Windows.Visibility.Hidden; |
|
WindowManager.mainViewModel.Content = vm; |
|
WindowManager.openContent.Add(vm); |
|
//} |
|
} |
|
catch (Exception e) |
|
{ |
|
// 记录日志 |
|
LogError(e); |
|
ShowMessage("Error: " + e.Message); |
|
} |
|
} |
|
|
|
private void ShowMessage(string message) |
|
{ |
|
MessageBox messageBox = new MessageBox(); |
|
messageBox.Show(message); |
|
} |
|
|
|
private void LogError(Exception e) |
|
{ |
|
// 实现日志记录逻辑,例如写入文件或数据库 |
|
// Console.WriteLine($"Error: {e.Message}\n{e.StackTrace}"); |
|
Logger.Error($"Error: {e.Message}\n{e.StackTrace}"); |
|
} |
|
|
|
|
|
} |