From 5e68543fd93e441e1e76acc3f439594f66c4412a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 18 Jan 2018 16:20:02 +0200 Subject: Removed Deleted from most of DB Tables !!!!!!!!!!! --- .../ViewModels/MainViewVM.cs | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs') 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 /// public RelayCommand RemoveIdsCommand { get; set; } + /// + /// Gets or sets the set version configuration command. + /// + public RelayCommand SetVersionConfigurationCommand { get; set; } + + /// + /// Gets or sets the set as default command. + /// + 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); } + /// + /// Sets the current configuration to the selected machine version default configuration. + /// + private void SetVersionConfiguration() + { + if (Machine.MachineVersions != null) + { + Configuration = Machine.MachineVersions.Configuration.CloneConfiguration(); + } + else + { + _notification.ShowError("No machine version selected."); + } + } + + /// + /// Sets the current configuration as a default machine version configuration. + /// + private void SetAsDefaultConfiguration() + { + _notification.ShowModalDialog(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 } } -- cgit v1.3.1