From afb6bbb2123932b3562e1af993eb847d8147bf58 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 26 Feb 2020 18:25:52 +0200 Subject: Major Changes Regarding RML & SPOOL parameters changes! --- .../Tango.MachineStudio.RML.csproj | 7 ++ .../ViewModels/MainViewVM.cs | 74 +++++++++++++++++-- .../Views/ProcessParametersView.xaml | 2 +- .../Tango.MachineStudio.RML/Views/RmlView.xaml | 9 ++- .../Tango.MachineStudio.RML/Views/SpoolsView.xaml | 85 ++++++++++++++++++++++ .../Views/SpoolsView.xaml.cs | 28 +++++++ 6 files changed, 195 insertions(+), 10 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj index 2ff9ab0a3..9f3a95e0b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj @@ -118,6 +118,9 @@ RmlView.xaml + + SpoolsView.xaml + ResXFileCodeGenerator Resources.Designer.cs @@ -223,6 +226,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + 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 _spoolTypes; + public ObservableCollection 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(); } + } + + /// /// Gets or sets the manage RML command. /// @@ -192,6 +207,16 @@ namespace Tango.MachineStudio.RML.ViewModels public RelayCommand ImportRMLFileCommand { get; set; } + /// + /// Gets or sets the add spool command. + /// + public RelayCommand AddSpoolCommand { get; set; } + + /// + /// Gets or sets the remove spool command. + /// + 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 } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml index cae614aeb..03bf65522 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml @@ -32,7 +32,7 @@ - ACTIVE PROCESS GROUP + ACTIVE PROCESS GROUP diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml index 2c8d538d0..6ee41ac38 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml @@ -159,18 +159,18 @@ - + - COLOR CONVERSION + COLOR CONVERSION - + @@ -211,6 +211,9 @@ + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml new file mode 100644 index 000000000..6eae05c76 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + SPOOLS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs new file mode 100644 index 000000000..6e363681c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.RML.Views +{ + /// + /// Interaction logic for SpoolsView.xaml + /// + public partial class SpoolsView : UserControl + { + public SpoolsView() + { + InitializeComponent(); + } + } +} -- cgit v1.3.1