private void ViewModel_CommandHandler(object sender, string e) { switch (e) { case "Plot.Refresh": PlotViewModel.InvalidatePlot(true); break; case "Table.Refresh": TableViewModel.Refresh(); break; case "DataGrid.Refresh": SeriesOnlineDataGridModelView.Refresh(); break; case "Main.ImportXML": ImportSeriesXML(SeriesOnlineDataGridModelView.FilePath); break; case "Main.ExportXML": ExportSeriesXML(SeriesOnlineDataGridModelView.FilePath); break; } }
public MainWindowViewModel() { //Load settings from settings.xml //string settingsFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "settings.xml"); string settingsFileName = "settings.xml"; LoadSettings(settingsFileName); //As default in properties region if (Series == default(ObservableCollection <Serie>)) { Series = new ObservableCollection <Serie>(); } ConnectionViewModel = new ConnectionViewModel(plc); ConnectionViewModel.CommandHandler += ViewModel_CommandHandler; PlotViewModel = new PlotViewModel(plot, Series); PlotViewModel.CommandHandler += ViewModel_CommandHandler; TableViewModel = new TableViewModel(Series); TableViewModel.CommandHandler += ViewModel_CommandHandler; SeriesOnlineDataGridViewModel = new SeriesOnlineDataGridModelView(Series); SeriesOnlineDataGridViewModel.CommandHandler += ViewModel_CommandHandler; SeriesArchiveDataGridViewModel = new SeriesArchiveDataGridModelView(Series); SeriesArchiveOnlineDataGridViewModel.CommandHandler += ViewModel_CommandHandler; plc.ConnectionStatusChanged += Plc_ConnectionStatusChanged; plc.ConnectionStatusChanged += PlotViewModel.ConnectionStatusChanged; //ConnectionViewModel.Refresh(); Series.CollectionChanged += Series_CollectionChanged; //suszarka = new Serie("Suszarka", 150); getValuesTimer = new System.Timers.Timer(); getValuesTimer.Elapsed += GetValuesTimer_Elapsed; //Series.Add(suszarka); //TODO //Strzałka aby rozciągnąć Y na górę i dół na maksa //getValuesTimer.Interval = interval * 1000; //getValuesTimer.Enabled = true; }
public MainWindowViewModel() { this.ParentViewModel = null; this.StringBuilder = new StringBuilder(); SeriesOnline = new ObservableCollection <Serie>(); SeriesArchive = new ObservableCollection <Serie>(); SeriesUsb = new ObservableCollection <Serie>(); ConnectionViewModel = new ConnectionViewModel(this, plc); ConnectionViewModel.CommandHandler += ViewModel_CommandHandler; //Load settings from settings.xml //string settingsFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "settings.xml") //As default in properties region PlotViewModel = new PlotViewModel(this, plot, SeriesOnline); PlotViewModel.CommandHandler += ViewModel_CommandHandler; TableViewModel = new TableViewModel(this, SeriesOnline); TableViewModel.CommandHandler += ViewModel_CommandHandler; SeriesOnlineDataGridViewModel = new SeriesOnlineDataGridModelView(this, SeriesOnline); SeriesOnlineDataGridViewModel.CommandHandler += ViewModel_CommandHandler; PlotArchiveViewModel = new PlotViewModel(this, plotArchive, SeriesArchive); PlotArchiveViewModel.CommandHandler += ViewModel_CommandHandler; TableArchiveViewModel = new TableViewModel(this, SeriesArchive); TableArchiveViewModel.CommandHandler += ViewModel_CommandHandler; SeriesArchiveDataGridViewModel = new SeriesArchiveDataGridViewModel(this, SeriesArchive); SeriesArchiveDataGridViewModel.CommandHandler += ViewModel_CommandHandler; ConnectionTerminalViewModel = new ConnectionTerminalViewModel(this); PlotUsbViewModel = new PlotViewModel(this, plotUsb, SeriesUsb); PlotUsbViewModel.CommandHandler += ViewModel_CommandHandler; TableUsbViewModel = new TableViewModel(this, SeriesUsb); TableUsbViewModel.CommandHandler += ViewModel_CommandHandler; SeriesUsbDataGridViewModel = new SeriesUsbDataGridViewModel(this, SeriesUsb); SeriesUsbDataGridViewModel.CommandHandler += ViewModel_CommandHandler; EditSettings = new RelayCommand(EditSettingsAction); LoadSettings(); plc.ConnectionStatusChanged += Plc_ConnectionStatusChanged; plc.ConnectionStatusChanged += PlotViewModel.ConnectionStatusChanged; //ConnectionViewModel.Refresh(); SeriesOnline.CollectionChanged += Series_CollectionChanged; //suszarka = new Serie("Suszarka", 150); getValuesTimer = new System.Timers.Timer(); getValuesTimer.Elapsed += GetValuesTimer_Elapsed; SelectedTabIndex = 0; //Series.Add(suszarka); //TODO //Strzałka aby rozciągnąć Y na górę i dół na maksa //getValuesTimer.Interval = interval * 1000; //getValuesTimer.Enabled = true; }