2025-07-02 18:33:08 +08:00
|
|
|
|
using System.Windows;
|
2025-06-23 17:01:06 +08:00
|
|
|
|
using System.Windows.Controls;
|
2025-07-03 20:12:07 +08:00
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
using System.Windows.Media;
|
2025-07-19 11:11:01 +08:00
|
|
|
|
using DMS.WPF.ViewModels;
|
2025-09-04 19:59:35 +08:00
|
|
|
|
using DMS.WPF.Interfaces;
|
2025-09-04 17:29:24 +08:00
|
|
|
|
using DMS.WPF.Services;
|
2025-07-02 18:33:08 +08:00
|
|
|
|
using iNKORE.UI.WPF.Modern.Controls;
|
2025-06-30 14:19:22 +08:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2025-07-02 18:33:08 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2025-07-03 20:12:07 +08:00
|
|
|
|
using NLog;
|
2025-07-18 22:21:16 +08:00
|
|
|
|
using DMS.Core.Enums;
|
2025-09-11 11:04:07 +08:00
|
|
|
|
using DMS.WPF.ViewModels.Items;
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
2025-07-19 11:11:01 +08:00
|
|
|
|
namespace DMS.WPF.Views;
|
2025-06-23 17:01:06 +08:00
|
|
|
|
|
|
|
|
|
|
public partial class VariableTableView : UserControl
|
|
|
|
|
|
{
|
2025-07-03 20:12:07 +08:00
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
2025-07-02 18:33:08 +08:00
|
|
|
|
public bool IsLoadCompletion;
|
2025-07-03 20:12:07 +08:00
|
|
|
|
private VariableTableViewModel _viewModel;
|
2025-07-02 18:33:08 +08:00
|
|
|
|
|
2025-06-30 14:19:22 +08:00
|
|
|
|
public VariableTableView()
|
2025-06-23 17:01:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2025-07-02 18:33:08 +08:00
|
|
|
|
IsLoadCompletion = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async void OnIsActiveChanged(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2025-07-03 20:12:07 +08:00
|
|
|
|
_viewModel = (VariableTableViewModel)this.DataContext;
|
2025-07-02 18:33:08 +08:00
|
|
|
|
// 判断如果没有加载完成就跳过,防止ToggleSwtich加载的时候触发
|
|
|
|
|
|
if (!_viewModel.IsLoadCompletion || !IsLoadCompletion)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
ToggleSwitch toggleSwitch = (ToggleSwitch)sender;
|
|
|
|
|
|
await _viewModel.OnIsActiveChanged(toggleSwitch.IsOn);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
|
{
|
2025-09-04 19:59:35 +08:00
|
|
|
|
var notificationService = App.Current.Services.GetRequiredService<INotificationService>();
|
2025-09-04 17:29:24 +08:00
|
|
|
|
notificationService.ShowError($"修改变量表启用,停用时发生了错误:{exception.Message}", exception);
|
2025-07-02 18:33:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void VariableTableView_OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
IsLoadCompletion = true;
|
2025-06-23 17:01:06 +08:00
|
|
|
|
}
|
2025-08-24 17:48:33 +08:00
|
|
|
|
|
2025-09-11 11:04:07 +08:00
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
}
|