/// <summary> /// Handle Simulation User Interface Button Click Event /// </summary> /// <param name="mode">0: pause, 1: continue, 2: foward</param> /// <param name="nprints">forward only, number prints to simulate forward</param> public void HandleSimControlClick(int mode, int nprints) { if (DataFeedSim.DataFileHasEnded) { MessageBox.Show("Simulation at end of data file. To restart simulation, please close and restart the application.", "End of Data File"); return; } switch (mode) { case 0: // pause DataFeedSim.StopSimulation(); DBuilder.DataUpdate -= MWindow.VM.HandleDataUpdate; break; case 1: // continue DataFeedSim.StartSimulation(); DBuilder.DataUpdate += MWindow.VM.HandleDataUpdate; break; case 2: // foward if (!DataFeedSim.SimExternalContinue) { DataFeedSim.StartSimulation(nprints, 0, false); // run simulation synchronously nprints with no pause in between if (!DataFeedSim.DataFileHasEnded) { MWindow.VM.NewData(true); // update graphical user interface } } break; } }
/// <summary> /// Handle window close, shutdown simulation then application /// </summary> public void HandleWindowClosed(object o, EventArgs e) { // end simulation, shutdown app on main window close DataFeedSim.StopSimulation(); Application.Current.Shutdown(); }