// private FileStream Stream; public MainViewModel(IUnityContainer container, IEventAggregator eventAggregator, IRegionManager regionManager, IServiceLocator serviceLocator, IHcdzClient hcdzClient) { _container = container; _eventAggregator = eventAggregator; _regionManager = regionManager; _serviceLocator = serviceLocator; _hcdzClient = hcdzClient; //devicesItems = new ObservableCollection<PCIE_Device>(); dispatcherTimer = new DispatcherTimer(DispatcherPriority.Background) { Interval = TimeSpan.FromSeconds(1) }; dispatcherTimer.Tick += DispatcherTimer_Tick; _openDeviceText = "连接设备"; OpenDevice = new DelegateCommand <object>(OnOpenDevice); ScanDeviceCmd = new DelegateCommand <object>(OnScanDevice); ReadDmaCmd = new DelegateCommand <object>(OnReadDma); CloseDmaCmd = new DelegateCommand <object>(OnCloseReadDma); OpenChannel = new DelegateCommand <DeviceChannelModel>(OnOpenChannel); CloseChannel = new DelegateCommand <DeviceChannelModel>(OnCloseChannel); ConnectClick = new DelegateCommand <TcpClientViewModel>(OnConnectTcp); CloseClick = new DelegateCommand <TcpClientViewModel>(OnCloseTcp); LocalDataJxCmd = new DelegateCommand <object>(OnLocalDataRead); SelectedDirCmd = new DelegateCommand <object>(OnLoadSelectDir); _deviceChannelModels = new ObservableCollection <DeviceChannelModel>(); //主板1 四通道 // _deviceChannel2 = new ObservableCollection<DeviceChannelModel>();//主板2 通道 _tcpViewModel = new ObservableCollection <TcpClientViewModel>(); _viewModel = new PcieViewModel(); // Stream = new FileStream("D:\\test", FileMode.Append, FileAccess.Write); _hcdzClient.MessageReceived += OnMessageReceived; _hcdzClient.Connected += ClientConnected; _hcdzClient.Connect(); _hcdzClient.NotifyTotal += _hcdzClient_NotifyTotal; _hcdzClient.NoticeScanByte += OnNoticeScanByte; _hcdzClient.NoticeTcpConnect += NoticeTcpConnect; _hcdzClient.NoticeTcpData += NoticeTcpData; LoadDeviceChannel(); InitRefresh(); Application.Current.Exit += Current_Exit; Application.Current.MainWindow.Closing += MainWindow_Closing; Application.Current.MainWindow.Closed += MainWindow_Closed; }