handefeng 8 months ago
parent 7be3c8edb4
commit 1a673f7b19
  1. 45
      ViewModel/BaseWindow/HomeWindowVM.cs

@ -1,15 +1,20 @@
using System.Windows; using System.IO;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using HandyControl.Controls; using HandyControl.Controls;
using SparkClient.Model.Helper; using SparkClient.Model.Helper;
using SparkClient.Model.Services;
using SparkClient.ViewModel.Configuration; using SparkClient.ViewModel.Configuration;
using SparkClient.ViewModel.Grading; using SparkClient.ViewModel.Grading;
using MessageBox = System.Windows.MessageBox;
namespace SparkClient.ViewModel.BaseWindow; namespace SparkClient.ViewModel.BaseWindow;
public class HomeWindowVM : BaseViewModel public class HomeWindowVM : BaseViewModel
{ {
private SOCClientService _socClientService;
public ICommand ShowHelperPageCommand { get; } public ICommand ShowHelperPageCommand { get; }
public ICommand ShowConfigPageCommand { get; } public ICommand ShowConfigPageCommand { get; }
@ -20,6 +25,9 @@ public class HomeWindowVM : BaseViewModel
ShowHelperPageCommand = new RelayCommand(ShowHelperPage); ShowHelperPageCommand = new RelayCommand(ShowHelperPage);
ShowConfigPageCommand = new RelayCommand(ShowConfigPage); ShowConfigPageCommand = new RelayCommand(ShowConfigPage);
ShowDiamondSelPageCommand = new RelayCommand(ShowDiamlondSelPage); ShowDiamondSelPageCommand = new RelayCommand(ShowDiamlondSelPage);
// 初始化SOC客户端服务,传入SOC端的地址和认证Token
_socClientService = new SOCClientService("http://localhost:5000/api/SoC", "your_basic_auth_token");
} }
public void ShowHelperPage(object parameter) public void ShowHelperPage(object parameter)
@ -36,10 +44,43 @@ public class HomeWindowVM : BaseViewModel
WindowManager.openContent.Add(vm); WindowManager.openContent.Add(vm);
} }
public void ShowDiamlondSelPage(object parameter) 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")); BaseControlVM vm = new BaseControlVM(new GradingResultVM(null), MultilingualHelper.getString("DetectionResult"));
WindowManager.mainViewModel.Content = vm; WindowManager.mainViewModel.Content = vm;
WindowManager.openContent.Add(vm); WindowManager.openContent.Add(vm);
} }
catch (Exception e)
{
// 记录日志
LogError(e);
ShowMessage("错误: " + e.Message);
}
}
private void ShowMessage(string message)
{
MessageBox.Show(message);
}
private void LogError(Exception e)
{
// 实现日志记录逻辑,例如写入文件或数据库
Console.WriteLine($"Error: {e.Message}\n{e.StackTrace}");
}
} }
Loading…
Cancel
Save