27 private Action<string> switchLanguage;
43 get {
return currentTopPanelViewModel; }
44 set { currentTopPanelViewModel = value; OnPropertyChanged(
"CurrentTopPanelViewModel"); }
65 get {
return constructionViewModel; }
77 get {
return simulationControlViewModel; }
84 private string geometricTopologyName;
89 public string GeometricTopologyName
91 get {
return geometricTopologyName; }
92 set { geometricTopologyName = value; OnPropertyChanged(
"GeometricTopologyName"); }
98 private bool hasChangesSaved;
102 public bool HasChangesSaved
104 get {
return hasChangesSaved; }
105 set { hasChangesSaved = value; OnPropertyChanged(
"HasChangesSaved"); }
114 private bool HasChangesSavedOrIsNeverSavedAndEmpty
118 return hasChangesSaved ||
121 constructionViewModel.GeometricTopology.IsEmpty));
128 private string uiCultureName;
132 public string UICultureName
134 get {
return uiCultureName; }
135 set { uiCultureName = value; OnPropertyChanged(
"UICultureName"); }
141 private ICommand newGeometricTopologyCommand;
145 public ICommand NewGeometricTopologyCommand
149 if (newGeometricTopologyCommand == null)
151 newGeometricTopologyCommand =
154 return newGeometricTopologyCommand;
161 private ICommand openGeometricTopologyCommand;
165 public ICommand OpenGeometricTopologyCommand
169 if (openGeometricTopologyCommand == null)
171 openGeometricTopologyCommand =
174 return openGeometricTopologyCommand;
181 private ICommand saveGeometricTopologyAsCommand;
185 public ICommand SaveGeometricTopologyAsCommand
189 if (saveGeometricTopologyAsCommand == null)
192 i => ChooseGeometricTopologyAndSaveItAs());
194 return saveGeometricTopologyAsCommand;
201 private ICommand saveGeometricTopologyCommand;
205 public ICommand SaveGeometricTopologyCommand
209 if (saveGeometricTopologyCommand == null)
212 i => ChooseGeometricTopologyAndSaveIt(), i => !hasChangesSaved);
214 return saveGeometricTopologyCommand;
221 private ICommand switchLanguageCommand = null;
225 public ICommand SwitchLanguageCommand
229 if (switchLanguageCommand == null)
232 uiCultureName => SwitchLanguage((
string)uiCultureName));
234 return switchLanguageCommand;
250 currentTopPanelViewModel = constructionViewModel;
253 (geometricTopology, parameters) => CurrentTopPanelViewModel = simulationControlViewModel);
255 () => CurrentTopPanelViewModel = constructionViewModel);
257 () => HasChangesSaved =
false);
259 this.interactions = interactions;
260 this.settings = settings;
261 this.switchLanguage = switchLanguage;
270 public void Initialize(
string newTopologyName,
string languageOnStartup)
272 UICultureName = languageOnStartup;
276 NewGeometricTopology(newTopologyName);
287 NewGeometricTopology(newTopologyName);
296 internal void NewGeometricTopology(
string newTopologyName)
299 if (!TestIfCurrentTopologyChangesAreSavedAndAskForAction())
302 GeometricTopologyName = newTopologyName;
305 constructionViewModel.CreateNewGeometricTopology();
306 HasChangesSaved =
false;
307 OnAnotherTopologyCreatedOrOpened();
308 CurrentTopPanelViewModel = constructionViewModel;
315 private void OpenGeometricTopology(
string path)
317 constructionViewModel.OpenGeometricTopology(path);
318 GeometricTopologyName = Path.GetFileNameWithoutExtension(path);
319 HasChangesSaved =
true;
322 OnAnotherTopologyCreatedOrOpened();
323 CurrentTopPanelViewModel = constructionViewModel;
330 private void SaveGeometricTopology(
string path)
332 constructionViewModel.SaveGeometricTopology(path);
333 GeometricTopologyName = Path.GetFileNameWithoutExtension(path);
334 HasChangesSaved =
true;
342 private void ChooseGeometricTopologyAndOpenIt()
344 if (!TestIfCurrentTopologyChangesAreSavedAndAskForAction())
348 if (pathToOpeningTopologyFile == null)
352 OpenGeometricTopology(pathToOpeningTopologyFile);
364 private void ChooseGeometricTopologyAndSaveIt()
367 ChooseGeometricTopologyAndSaveItAs();
385 private void ChooseGeometricTopologyAndSaveItAs()
388 if (pathToSaveTopologyFile == null)
392 SaveGeometricTopology(pathToSaveTopologyFile);
404 private bool TestIfCurrentTopologyChangesAreSavedAndAskForAction()
406 if (!HasChangesSavedOrIsNeverSavedAndEmpty)
412 else if (result.Value)
418 if (savePath == null)
425 SaveGeometricTopology(savePath);
441 private void SwitchLanguage(
string uiCultureName)
443 switchLanguage(uiCultureName);
444 UICultureName = uiCultureName;
451 internal bool CanBeClosed()
453 return TestIfCurrentTopologyChangesAreSavedAndAskForAction();
459 private void OnAnotherTopologyCreatedOrOpened()
466 if (AnotherTopologyInitializedOrOpened != null)
467 AnotherTopologyInitializedOrOpened(
this, EventArgs.Empty);
477 return parametersViewModel;
void Initialize(string newTopologyName, string languageOnStartup)
Creates new or open last opened geometric topology.
void ScreamErrorMessage(string errorMessage)
Screaming error message.
Viewmodel for construction panel.
Interface of application settings.
string LastGeometricTopologyPath
Item for path to file where is the last opened topology.
Class representing messenger for communicating between viewmodels.
EventHandler AnotherTopologyInitializedOrOpened
Event for initialization or opening of new topology.
Command class for binding UI commands with view models.
SimulationState
Current state of the simulation.
Viewmodel for canvas panel.
Main application viewmodel.
Message for sending information about modification of geometric topology.
Interface for interactions with user.
void Initialize()
Initialize parameters view model by getting last used or default parameters.
bool SaveChangesYesNoCancel()
Asking whether to save changes or not or if to interrupt the starting action.
MainViewModel(IInteractions interactions, ISettings settings, Action< string > switchLanguage)
Initialization of main viewmodel.
Class representing view model of parameters view.
string GetPathToOpenTopologyFile()
Asking which topology file to open for loading.
Message for sending geometric topology simulation control viewmodel to build cellular topology from i...
Extended relay command class by adding event after executing command. Useful for performing additiona...
Viewmodel for simulation control.
Class for sending message about switching top panel to construction panel.
void Save()
Saves application settings.
string GetPathToSaveTopologyFile()
Asking which topology file the data to be saved into.