aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
index 96b66c204..24f2f6d43 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
@@ -123,6 +123,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
/// </summary>
public RelayCommand RemoveIdsCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the set version configuration command.
+ /// </summary>
+ public RelayCommand SetVersionConfigurationCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the set as default command.
+ /// </summary>
+ public RelayCommand SetAsDefaultCommand { get; set; }
+
#endregion
#region Constructors
@@ -143,6 +153,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
SaveCommand = new RelayCommand(Save, (x) => !_isSaving);
AddIdsCommand = new RelayCommand(AddIds, (x) => !_isSaving && Configuration.IdsPacks.Count < 8);
RemoveIdsCommand = new RelayCommand(RemoveIds, (x) => !_isSaving && SelectedIds != null);
+ SetVersionConfigurationCommand = new RelayCommand(SetVersionConfiguration,(x) => !_isSaving);
+ SetAsDefaultCommand = new RelayCommand(SetAsDefaultConfiguration,(x) => !_isSaving);
}
#endregion
@@ -563,6 +575,61 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
History.Insert(0, machine.Configuration);
}
+ /// <summary>
+ /// Sets the current configuration to the selected machine version default configuration.
+ /// </summary>
+ private void SetVersionConfiguration()
+ {
+ if (Machine.MachineVersions != null)
+ {
+ Configuration = Machine.MachineVersions.Configuration.CloneConfiguration();
+ }
+ else
+ {
+ _notification.ShowError("No machine version selected.");
+ }
+ }
+
+ /// <summary>
+ /// Sets the current configuration as a default machine version configuration.
+ /// </summary>
+ private void SetAsDefaultConfiguration()
+ {
+ _notification.ShowModalDialog<MachineVersionDialogVM>(async (vm) =>
+ {
+ try
+ {
+ using (_notification.PushTaskItem("Saving Default Configuration..."))
+ {
+ if (vm.SelectedVersion != null)
+ {
+ vm.SelectedVersion.Configuration = Configuration.CloneConfiguration();
+ vm.SelectedVersion.DefaultConfigurationGuid = vm.SelectedVersion.Configuration.Guid;
+ await vm.SelectedVersion.SaveAsync();
+ }
+ else
+ {
+ MachineVersion newVersion = new MachineVersion();
+ newVersion.Version = vm.Version;
+ newVersion.Name = vm.VersionName;
+
+ newVersion.Configuration = Configuration.CloneConfiguration();
+ newVersion.DefaultConfigurationGuid = newVersion.Configuration.Guid;
+ await newVersion.SaveAsync();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ _notification.ShowError(ex.Message);
+ }
+
+ }, () =>
+ {
+
+ });
+ }
+
#endregion
}
}