From 95cabc98a8cd6baebc697c179be9fb68913ac483 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 4 Dec 2018 17:46:26 +0200 Subject: Fixed issue with LeastParameterTables index. --- .../ViewModels/MainViewVM.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels') 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 70073ad62..ef6fc816b 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 @@ -209,6 +209,34 @@ namespace Tango.MachineStudio.RML.ViewModels .WithMediaProperties() .BuildAsync(); + if (ActiveRML.ProcessParametersTablesGroups.ToList().Count == 0) + { + if (!_notification.ShowQuestion("Could not find any process group for the selected RML. Would you like to create one?")) + { + _notification.ShowError("Cannot load an RML with no process group."); + IsFree = true; + return; + } + else + { + ProcessParametersTablesGroup group = new ProcessParametersTablesGroup(); + group.Name = "Active Group"; + group.Active = true; + group.ProcessParametersTables.Add(new ProcessParametersTable() + { + Name = "Process Table 1", + }); + + group.Rml = ActiveRML; + + _active_context.ProcessParametersTablesGroups.Add(group); + _active_context.ProcessParametersTables.Add(group.ProcessParametersTables[0]); + await _active_context.SaveChangesAsync(); + LoadActiveRML(ActiveRML.Guid); + return; + } + } + ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault(); ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables); ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending)); -- cgit v1.3.1