public void ResetButtonClick() { Screen.BtnStart.IsEnabled = true; Screen.BtnLoad.IsEnabled = true; Screen.BtnSelect.IsEnabled = true; Screen.BtnPause.IsEnabled = false; Screen.BtnStop.IsEnabled = false; Screen.TabItemSettings.IsEnabled = true; App.Console.Print("Reset pressed"); LoadButtonClick(); ResetLabels(); Screen.Ticks = 0; Screen.UpdateTimer(); MainScreen.WPFLoop.Stop(); MainScreen.AILoop.Stop(); CitySystem.City.Instance.Controller.Reset(); SimulationLoad?.Invoke(this, new SimulationEventArgs(CitySystem.City.Instance)); }
public void LoadButtonClick() { // Loads the city file and parses the information into a City. var file = new XmlDocument(); try { file.Load(SelectedFilePath); } catch (Exception ex) { MessageBox.Show("Please select a City", "No city selected!", MessageBoxButton.OK, MessageBoxImage.Warning); return; } try { var cityname = Screen.TBCity.Text; CityParser.MakeCity(file, cityname.First().ToString().ToUpper() + cityname.Substring(1)); } catch (Exception ex) { MessageBox.Show("There is an error in the city file.", "Invalid City File", MessageBoxButton.OK, MessageBoxImage.Error); return; } var city = CitySystem.City.Instance; Screen.CityRenderHandler.DrawCity(city); Screen.PropertyDisplayHandler.UpdateProperties(); EnableButtonsAndTabs(); UpdateCountLabels(city); SimulationLoad?.Invoke(this, new SimulationEventArgs(CitySystem.City.Instance)); }