EquipmentPropMonitor.xaml.cs 1.11 KB
using HHECS.DAQClient.ViewModel.EquipmentPropVM;
using HHECS.EquipmentModel;
using Microsoft.Extensions.DependencyInjection;
using System.Windows;

namespace HHECS.DAQClient.View.EquipmentPropView
{
    /// <summary>
    /// EquipmentPropMonitor.xaml 的交互逻辑
    /// </summary>
    public partial class EquipmentPropMonitor : Window
    {
        private readonly CancellationTokenSource _cancellationTokenSource;

        /// <summary>
        /// 设备Id
        /// </summary>
        /// <param name="equipmentId"></param>
        public EquipmentPropMonitor(Equipment equipment)
        {
            InitializeComponent();
            _cancellationTokenSource = new CancellationTokenSource();
            var dataContext = App.Current.Services.GetService<EquipmentPropMonitorVM>();
            dataContext.Owner = this;
            dataContext.InitialData(equipment, _cancellationTokenSource);
            this.DataContext = dataContext;
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            _cancellationTokenSource.Cancel();
        }
    }
}