aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-18 16:20:02 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-18 16:20:02 +0200
commit5e68543fd93e441e1e76acc3f439594f66c4412a (patch)
treed64d3d48f1e91723c70a16b484be4cb456584ac1 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels
parent448632f4057e9a81b8bc80701296dcd4ec622877 (diff)
downloadTango-5e68543fd93e441e1e76acc3f439594f66c4412a.tar.gz
Tango-5e68543fd93e441e1e76acc3f439594f66c4412a.zip
Removed Deleted from most of DB Tables !!!!!!!!!!!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs61
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs67
2 files changed, 128 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs
new file mode 100644
index 000000000..6854472f1
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineVersionDialogVM.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core.Commands;
+using Tango.DAL.Observables;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.MachineStudio.MachineDesigner.AutoComplete;
+
+namespace Tango.MachineStudio.MachineDesigner.ViewModels
+{
+ public class MachineVersionDialogVM : DialogViewVM
+ {
+ public MachineVersionsProvider VersionsProvider { get; set; }
+
+ public double Version { get; set; }
+
+ private String _versionName;
+
+ public String VersionName
+ {
+ get { return _versionName; }
+ set { _versionName = value; RaisePropertyChangedAuto(); }
+ }
+
+ private MachineVersion _selectedVersion;
+
+ public MachineVersion SelectedVersion
+ {
+ get { return _selectedVersion; }
+ set
+ {
+ _selectedVersion = value;
+ RaisePropertyChangedAuto();
+ VersionName = value != null ? value.Name : null;
+ Version = value != null ? value.Version : 0;
+ }
+ }
+
+ public RelayCommand AcceptCommand { get; set; }
+
+ public RelayCommand CancelCommand { get; set; }
+
+ public MachineVersionDialogVM()
+ {
+ VersionsProvider = new MachineVersionsProvider();
+ AcceptCommand = new RelayCommand(() =>
+ {
+ if (SelectedVersion == null)
+ {
+ Version = double.Parse(VersionsProvider.Text);
+ }
+
+ Accept();
+
+ });
+ CancelCommand = new RelayCommand(Cancel);
+ }
+ }
+}
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
}
}