Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

ConstructionViewModel.cs
Go to the documentation of this file.
1 using Microscopic_Traffic_Simulator.ViewModels.Messages;
2 using Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.GeneralParameters;
3 using Microscopic_Traffic_Simulator___Model.GeometricObjects;
4
5 namespace Microscopic_Traffic_Simulator.ViewModels
6 {
10 internal enum BuildingMode { None, Lane, Generator }
11
15 internal enum LaneType { Straight, Bezier }
16
20 internal enum GeneratorType { Generator, Sensor }
21
25 class ConstructionViewModel : ViewModelBase
26 {
31 internal class GeometricTopologyMessage : ParameterizedMessage<GeometricTopology> { }
32
36 internal class GeometricTopologyModifiedMessage : Message { }
37
42 internal class BuildCellularTopologyMessage : ParameterizedMessage<GeometricTopology, Parameters> { }
43
47 internal class LaneTypeChangedMessage : ParameterizedMessage<LaneType> { }
48
52 internal class IsConstructionModeChangedMessage : ParameterizedMessage<BuildingMode> { }
53
57 private GeometricTopology geometricTopology;
61 internal GeometricTopology GeometricTopology { get { return geometricTopology; } }
62
66 private BuildingMode currentBuildingMode = BuildingMode.None;
70 public BuildingMode CurrentBuildingMode
71 {
72 get { return currentBuildingMode; }
73 set
74 {
75 currentBuildingMode = value;
76 messenger.GetEvent<IsConstructionModeChangedMessage>().Publish(value);
77 OnPropertyChanged("CurrentBuildingMode");
78 }
79 }
80
84 private LaneType currentLaneType = LaneType.Straight;
88 public LaneType CurrentLaneType
89 {
90 get { return currentLaneType; }
91 set
92 {
93 currentLaneType = value;
94 OnPropertyChanged("CurrentLaneType");
95 messenger.GetEvent<LaneTypeChangedMessage>().Publish(value);
96 }
97 }
98
102 private GeneratorType currentGeneratorType = GeneratorType.Generator;
106 public GeneratorType CurrentGeneratorType
107 {
108 get { return currentGeneratorType; }
109 set
110 {
111 currentGeneratorType = value;
112 OnPropertyChanged("CurrentGeneratorType");
113 }
114 }
115
121 internal ConstructionViewModel(Messenger messenger)
122 {
123 this.messenger = messenger;
124 messenger.GetEvent<ParametersViewModel.ParametersMessage>().Subscribe(i =>
125 messenger.GetEvent<BuildCellularTopologyMessage>().Publish(geometricTopology, i));
126 }
127
131 internal void CreateNewGeometricTopology()
132 {
133 geometricTopology = new GeometricTopology();
134 messenger.GetEvent<GeometricTopologyMessage>().Publish(geometricTopology);
135 }
136
141 internal void OpenGeometricTopology(string path)
142 {
143 geometricTopology = GeometricTopology.Deserialize(path);
144 messenger.GetEvent<GeometricTopologyMessage>().Publish(geometricTopology);
145 }
146
151 internal void SaveGeometricTopology(string path)
152 {
153 geometricTopology.Serialize(path);
154 }
155 }
156 }
Microscopic_Traffic_Simulator___Model.GeometricObjects.GeometricTopology
Class representing geometric topology of road network.
Definition: GeometricTopology.cs:14
Microscopic_Traffic_Simulator.ViewModels.Messages
Definition: Message.cs:4
Microscopic_Traffic_Simulator___Model.GeometricObjects.GeometricTopology.Serialize
void Serialize(string path)
Save geometric topology to file.
Definition: GeometricTopology.cs:43
Microscopic_Traffic_Simulator.ViewModels.Messages.ParameterizedMessage
Class representing message with payload.
Definition: ParameterizedMessage.cs:9
Microscopic_Traffic_Simulator.ViewModels.ConstructionViewModel
Viewmodel for construction panel.
Definition: ConstructionViewModel.cs:25
Microscopic_Traffic_Simulator.ViewModels.Messages.Messenger
Class representing messenger for communicating between viewmodels.
Definition: Messenger.cs:9
Microscopic_Traffic_Simulator.ViewModels
Definition: CanvasViewModel.cs:8
Microscopic_Traffic_Simulator___Model.GeometricObjects.GeometricTopology.Deserialize
static GeometricTopology Deserialize(string path)
Load geometric topology from file.
Definition: GeometricTopology.cs:56
Microscopic_Traffic_Simulator.ViewModels.ViewModelBase
Definition: ViewModelBase.cs:8
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects.GeneralParameters
Definition: CellularTopologyParameters.cs:3
Microscopic_Traffic_Simulator
Definition: App.xaml.cs:12
Microscopic_Traffic_Simulator.ViewModels.ParametersViewModel
Class representing view model of parameters view.
Definition: ParametersViewModel.cs:13
Microscopic_Traffic_Simulator.ViewModels.ParametersViewModel.ParametersMessage
Message sending the parameters to use in the simulation.
Definition: ParametersViewModel.cs:18
Microscopic_Traffic_Simulator___Model.CellularTopologyObjects
Definition: Car.cs:6
Microscopic_Traffic_Simulator___Model.GeometricObjects
Definition: GeometricTopology.cs:8
Microscopic_Traffic_Simulator___Model
Microscopic_Traffic_Simulator.ViewModels.Messages.Message
Class representing message without payload.
Definition: Message.cs:9