aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-02-26 18:25:52 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-02-26 18:25:52 +0200
commitafb6bbb2123932b3562e1af993eb847d8147bf58 (patch)
treea2c458a077551af5be35a729c4e6d976a92b9387 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
parent61f2658295193dca0fdaa58744925d90bd2f4044 (diff)
downloadTango-afb6bbb2123932b3562e1af993eb847d8147bf58.tar.gz
Tango-afb6bbb2123932b3562e1af993eb847d8147bf58.zip
Major Changes Regarding RML & SPOOL parameters changes!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs74
1 files changed, 68 insertions, 6 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
index 3b3a307ad..b75d65fe0 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs
@@ -87,6 +87,13 @@ namespace Tango.MachineStudio.RML.ViewModels
set { _fiberSynths = value; RaisePropertyChangedAuto(); }
}
+ private ObservableCollection<SpoolType> _spoolTypes;
+ public ObservableCollection<SpoolType> SpoolTypes
+ {
+ get { return _spoolTypes; }
+ set { _spoolTypes = value; RaisePropertyChangedAuto(); }
+ }
+
private Rml _selectedRML;
public Rml SelectedRML
{
@@ -150,6 +157,14 @@ namespace Tango.MachineStudio.RML.ViewModels
set { _colorConversionViewVM = value; RaisePropertyChangedAuto(); }
}
+ private RmlsSpool _selectedSpool;
+ public RmlsSpool SelectedSpool
+ {
+ get { return _selectedSpool; }
+ set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+
/// <summary>
/// Gets or sets the manage RML command.
/// </summary>
@@ -192,6 +207,16 @@ namespace Tango.MachineStudio.RML.ViewModels
public RelayCommand ImportRMLFileCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the add spool command.
+ /// </summary>
+ public RelayCommand AddSpoolCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the remove spool command.
+ /// </summary>
+ public RelayCommand RemoveSpoolCommand { get; set; }
+
public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager)
{
_notification = notificationProvider;
@@ -215,6 +240,9 @@ namespace Tango.MachineStudio.RML.ViewModels
ExportRMLFileCommand = new RelayCommand(ExportRmlFile, () => SelectedRML != null && IsFree);
ImportRMLFileCommand = new RelayCommand(ImportRmlFile, () => IsFree);
+
+ AddSpoolCommand = new RelayCommand(AddNewSpool);
+ RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null);
}
public override void OnApplicationReady()
@@ -281,6 +309,7 @@ namespace Tango.MachineStudio.RML.ViewModels
.WithActiveParametersGroup()
.WithLiquidFactors()
.WithCCT()
+ .WithSpools()
.BuildAsync();
if (ActiveRML.Cct != null)
@@ -382,6 +411,7 @@ namespace Tango.MachineStudio.RML.ViewModels
LinearMassDensityUnits = _active_context.LinearMassDensityUnits.ToObservableCollection();
FiberShapes = _active_context.FiberShapes.ToObservableCollection();
FiberSynths = _active_context.FiberSynths.ToObservableCollection();
+ SpoolTypes = _active_context.SpoolTypes.ToObservableCollection();
}
private async void AddNewRml()
@@ -495,7 +525,7 @@ namespace Tango.MachineStudio.RML.ViewModels
using (var context = ObservablesContext.CreateDefault())
{
- var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().BuildAsync();
+ var rml = await new RmlBuilder(context).Set(SelectedRML.Guid).WithActiveParametersGroup().WithLiquidFactors().WithSpools().BuildAsync();
Rml cloned = new Rml();
rml.MapPropertiesTo(cloned, MappingFlags.NoReferenceTypes);
@@ -532,6 +562,15 @@ namespace Tango.MachineStudio.RML.ViewModels
cloned.LiquidTypesRmls.Add(l);
}
+ foreach (var spool in rml.RmlsSpools)
+ {
+ RmlsSpool s = new RmlsSpool();
+ spool.MapPropertiesTo(s, MappingFlags.ValueTypesOnly);
+ s.RmlGuid = cloned.Guid;
+ s.SpoolTypeGuid = spool.SpoolTypeGuid;
+ cloned.RmlsSpools.Add(s);
+ }
+
context.Rmls.Add(cloned);
await context.SaveChangesAsync();
@@ -709,17 +748,19 @@ namespace Tango.MachineStudio.RML.ViewModels
_actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlSaved, _authentication.CurrentUser, _rmlBeforeSave.Name, _rmlBeforeSave, rmlAfter, "RML saved using Machine Studio.");
_rmlBeforeSave = rmlAfter;
+
+ LoadActiveRML(ActiveRML.Guid);
}
}
catch (Exception ex)
{
LogManager.Log(ex, $"Error saving RML {ActiveRML.Name}");
- _notification.ShowError($"An error occurred while trying to save the current RML.\n{ex.Message}");
+ _notification.ShowError($"An error occurred while trying to save the current RML.\n{ex.FlattenMessage()}");
+ }
+ finally
+ {
+ IsFree = true;
}
-
- LoadActiveRML(ActiveRML.Guid);
-
- IsFree = true;
}
private void BackToRmls()
@@ -905,5 +946,26 @@ namespace Tango.MachineStudio.RML.ViewModels
}
#endregion
+
+ #region Spools
+
+ private void AddNewSpool()
+ {
+ _active_context.RmlsSpools.Add(new RmlsSpool()
+ {
+ Rml = ActiveRML,
+ });
+ }
+
+ private void RemoveSpool()
+ {
+ if (SelectedSpool != null)
+ {
+ _active_context.RmlsSpools.Remove(SelectedSpool);
+ ActiveRML.RmlsSpools.Remove(SelectedSpool);
+ }
+ }
+
+ #endregion
}
}