2025-03-17 01:56:27 +08:00
|
|
|
|
using System.Windows;
|
2025-03-16 23:38:23 +08:00
|
|
|
|
using System.Windows.Controls;
|
2025-03-17 01:56:27 +08:00
|
|
|
|
using MaterialDesignThemes.Wpf;
|
|
|
|
|
using Seyounth.Hyosung.Data.Models;
|
|
|
|
|
using Seyounth.Hyosung.Runtime;
|
|
|
|
|
using Seyounth.Hyosung.ViewModels;
|
2025-03-16 23:38:23 +08:00
|
|
|
|
|
|
|
|
|
namespace Seyounth.Hyosung.Views.Pages
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// HomeViewPage.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class HomeViewPage : Page
|
|
|
|
|
{
|
2025-03-17 01:56:27 +08:00
|
|
|
|
public HomeViewModel ViewModel { get; set; }
|
|
|
|
|
|
|
|
|
|
private readonly IHyosungRuntime _runtime;
|
|
|
|
|
|
|
|
|
|
public HomeViewPage(HomeViewModel viewModel, IHyosungRuntime runtime)
|
2025-03-16 23:38:23 +08:00
|
|
|
|
{
|
2025-03-17 01:56:27 +08:00
|
|
|
|
_runtime = runtime;
|
|
|
|
|
ViewModel = viewModel;
|
|
|
|
|
DataContext = this;
|
2025-03-16 23:38:23 +08:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
2025-03-17 01:56:27 +08:00
|
|
|
|
|
|
|
|
|
private void ChangeVarietyButton_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var variety = VarietyComboBox.SelectedItem as Variety;
|
|
|
|
|
if (variety == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请选择要切换的品种");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChangeVarietyButton.Content = "切换中";
|
|
|
|
|
ButtonProgressAssist.SetIsIndicatorVisible(ChangeVarietyButton, true);
|
|
|
|
|
ChangeVarietyButton.IsEnabled = false;
|
|
|
|
|
|
|
|
|
|
variety.YarnCarSide = 1;
|
|
|
|
|
variety.YarnCarType = YarnCarTypeComboBox.SelectedIndex + 1;
|
|
|
|
|
_runtime.SendVarietyToPlcAsync(variety)
|
|
|
|
|
.ContinueWith(task =>
|
|
|
|
|
{
|
|
|
|
|
if (task.IsCompletedSuccessfully)
|
|
|
|
|
{
|
|
|
|
|
ChangeVarietyButton.Content = "切换";
|
|
|
|
|
ButtonProgressAssist.SetIsIndicatorVisible(ChangeVarietyButton, false);
|
|
|
|
|
ChangeVarietyButton.IsEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(task.Exception?.Message, "切换失败");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-03-16 23:38:23 +08:00
|
|
|
|
}
|
2025-03-17 01:56:27 +08:00
|
|
|
|
}
|