Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

MainWindow.xaml.cs
Go to the documentation of this file.
1 using Microscopic_Traffic_Simulator.ViewModels;
2 using System;
3 using System.Windows;
4
5 namespace Microscopic_Traffic_Simulator.Views.MainWindowView
6 {
10 public partial class MainWindow : Window
11 {
15 public MainWindow()
16 {
17 InitializeComponent();
18 }
19
26 private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
27 {
28 e.Cancel = !(DataContext as MainViewModel).CanBeClosed();
29 }
30
37 private void mainWindow_Loaded(object sender, RoutedEventArgs e)
38 {
39 MainViewModel mainViewModel = DataContext as MainViewModel;
40 (mainViewModel.NewGeometricTopologyCommand as ObservableRelayCommand)
41 .CommandExecuted += MainWindow_NewOpenCommandExecuted;
42 (mainViewModel.OpenGeometricTopologyCommand as ObservableRelayCommand)
43 .CommandExecuted += MainWindow_NewOpenCommandExecuted;
44 mainViewModel.AnotherTopologyInitializedOrOpened += mainViewModel_AnotherTopologyInitializedOrOpened;
45 }
46
52 void mainViewModel_AnotherTopologyInitializedOrOpened(object sender, EventArgs e)
53 {
54 // TODO isnt it redundant?
55 mainWindow.canvasUserControl.RoadPreviewer.ClearPreviewOfBuildingOfAnyRoads();
56 canvasUserControl.SimulationTrafficRenderer.DetachEventHandlerFromCellularTopology();
57 }
58
65 void MainWindow_NewOpenCommandExecuted(object sender, EventArgs e)
66 {
67 canvasUserControl.TopologyRenderer.GeometricTopology =
68 (canvasUserControl.DataContext as CanvasViewModel).GeometricTopology;
69 canvasUserControl.TopologyRenderer.RenderTopology();
70 mainWindow.canvasUserControl.RoadPreviewer.ClearPreviewOfBuildingOfAnyRoads();
71 }
72 }
73 }
System
Microscopic_Traffic_Simulator.ViewModels.MainViewModel.AnotherTopologyInitializedOrOpened
EventHandler AnotherTopologyInitializedOrOpened
Event for initialization or opening of new topology.
Definition: MainViewModel.cs:32
Microscopic_Traffic_Simulator.ViewModels
Definition: CanvasViewModel.cs:8
Microscopic_Traffic_Simulator.ViewModels.CanvasViewModel
Viewmodel for canvas panel.
Definition: CanvasViewModel.cs:13
Microscopic_Traffic_Simulator.ViewModels.MainViewModel
Main application viewmodel.
Definition: MainViewModel.cs:12
Microscopic_Traffic_Simulator.ViewModels.MainViewModel.NewGeometricTopologyCommand
ICommand NewGeometricTopologyCommand
Command for creating new geometric topology.
Definition: MainViewModel.cs:146
Microscopic_Traffic_Simulator.ViewModels.MainViewModel.OpenGeometricTopologyCommand
ICommand OpenGeometricTopologyCommand
Command for opening geometric topology.
Definition: MainViewModel.cs:166
Microscopic_Traffic_Simulator
Definition: App.xaml.cs:12
Microscopic_Traffic_Simulator.ObservableRelayCommand
Extended relay command class by adding event after executing command. Useful for performing additiona...
Definition: ObservableRelayCommand.cs:9
Microscopic_Traffic_Simulator.Views.MainWindowView.MainWindow.MainWindow
MainWindow()
Initialization of main window.
Definition: MainWindow.xaml.cs:15