void model_EventNewDevice() { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { DeviceItems.Clear(); model.GetDevices().ForEach(i => DeviceItems.Add(i)); LogMsgItems.Add("New device founded"); })); }
public MainViewModel() { //initialize isConnected = false; DeviceItems = new ObservableCollection <string>(); LogMsgItems = new ObservableCollection <string>(); CanMessagesItems = new ObservableCollection <CanMsg>(); DataCountItems = new ObservableCollection <int> { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; model = new UsbTinModel(); model.EventNewDevice += model_EventNewDevice; model.MessageEvent += model_MessageEvent; model.CanMsgEvent += model_CanMsgEvent; model.GetDevices().ForEach(i => DeviceItems.Add(i)); random = new Random(); TsendRandom = new System.Timers.Timer(500); TsendRandom.Elapsed += TsendRandom_Elapsed; ConnectCmd = new DelegateCommand(c => ExecuteConnectCmd(), c => !isConnected); DisconnectCmd = new DelegateCommand(c => ExecuteDisconnectCmd(), c => isConnected); ClearTraceCmd = new DelegateCommand(c => ExecuteClearTraceCmd(), c => true); SendCmd = new DelegateCommand(c => ExecuteSendCmd(), c => true); SaveTofileCmd = new DelegateCommand(c => ExecuteSaveTofileCmd(c), c => true); StartSendRandomCmd = new DelegateCommand(c => ExecuteStartSendRandomCmd(), c => IsConnected && !TsendRandom.Enabled); StopSendRandomCmd = new DelegateCommand(c => ExecuteStopSendRandomCmd(), c => IsConnected && TsendRandom.Enabled); ClearLogCmd = new DelegateCommand(c => ExecuteClearLogCmd(), c => true); //Init values selectedDevice = DeviceItems.First(); selectedBitRate = BaudRateItems[4]; selectedOpenMode = OpenModeItems[0]; Id = 0x01; D0 = 0x00; D1 = 0x11; D2 = 0x22; D3 = 0x33; D4 = 0x44; D5 = 0x55; D6 = 0x66; D7 = 0x77; }
public MainViewModel() { //initialize isConnected = false; DeviceItems = new ObservableCollection<string>(); LogMsgItems = new ObservableCollection<string>(); CanMessagesItems = new ObservableCollection<CanMsg>(); DataCountItems = new ObservableCollection<int> { 0, 1, 2, 3, 4, 5, 6, 7,8 }; model = new UsbTinModel(); model.EventNewDevice += model_EventNewDevice; model.MessageEvent += model_MessageEvent; model.CanMsgEvent += model_CanMsgEvent; model.GetDevices().ForEach(i => DeviceItems.Add(i)); random = new Random(); TsendRandom = new System.Timers.Timer(500); TsendRandom.Elapsed += TsendRandom_Elapsed; ConnectCmd = new DelegateCommand(c => ExecuteConnectCmd(), c => !isConnected); DisconnectCmd = new DelegateCommand(c => ExecuteDisconnectCmd(), c => isConnected); ClearTraceCmd = new DelegateCommand(c => ExecuteClearTraceCmd(), c => true); SendCmd = new DelegateCommand(c => ExecuteSendCmd(), c => true); SaveTofileCmd = new DelegateCommand(c => ExecuteSaveTofileCmd(c), c => true); StartSendRandomCmd = new DelegateCommand(c => ExecuteStartSendRandomCmd(), c => IsConnected && !TsendRandom.Enabled); StopSendRandomCmd = new DelegateCommand(c => ExecuteStopSendRandomCmd(), c => IsConnected && TsendRandom.Enabled); ClearLogCmd = new DelegateCommand(c => ExecuteClearLogCmd(), c => true); //Init values selectedDevice = DeviceItems.First(); selectedBitRate = BaudRateItems[4]; selectedOpenMode = OpenModeItems[0]; Id = 0x01; D0 = 0x00; D1 = 0x11; D2 = 0x22; D3 = 0x33; D4 = 0x44; D5 = 0x55; D6 = 0x66; D7 = 0x77; }