aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML
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
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')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Tango.MachineStudio.RML.csproj7
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs74
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/ProcessParametersView.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml9
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml85
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/SpoolsView.xaml.cs28
6 files changed, 195 insertions, 10 deletions
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 @@
<Compile Include="Views\RmlView.xaml.cs">
<DependentUpon>RmlView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\SpoolsView.xaml.cs">
+ <DependentUpon>SpoolsView.xaml</DependentUpon>
+ </Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -223,6 +226,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\SpoolsView.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\threads.png" />
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
}
}
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 @@
<DropShadowEffect Opacity="0.4" />
</Border.Effect>
<Grid>
- <TextBlock HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16">ACTIVE PROCESS GROUP</TextBlock>
+ <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16">ACTIVE PROCESS GROUP</TextBlock>
<Button ToolTip="Add new table" Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" Width="30" HorizontalAlignment="Right" Padding="0" Command="{Binding AddProcessParametersTableCommand}">
<materialDesign:PackIcon Kind="Plus" Foreground="#0AC30A" Width="24" Height="24" />
</Button>
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 @@
<ColumnDefinition Width="260"></ColumnDefinition>
</Grid.ColumnDefinitions>
<DockPanel>
- <Border DockPanel.Dock="Top" Background="{StaticResource TransparentBackgroundBrush200}" Margin="20 0" Padding="5" CornerRadius="5">
+ <Border DockPanel.Dock="Top" Background="{StaticResource TransparentBackgroundBrush200}" Margin="20 0" Padding="7" CornerRadius="5">
<Border.Effect>
<DropShadowEffect Opacity="0.4" />
</Border.Effect>
<Grid>
- <TextBlock HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16">COLOR CONVERSION</TextBlock>
+ <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16">COLOR CONVERSION</TextBlock>
</Grid>
</Border>
<local:ColorConversionView x:Name="colorConversionView" Margin="0 0 0 0" Grid.Column="0" DataContext="{Binding ColorConversionViewVM}"/>
</DockPanel>
<DockPanel Grid.Column="1">
- <Border DockPanel.Dock="Top" Background="{StaticResource TransparentBackgroundBrush200}" Margin="16 0" Padding="5" CornerRadius="5">
+ <Border DockPanel.Dock="Top" Background="{StaticResource TransparentBackgroundBrush200}" Margin="16 0" Padding="7" CornerRadius="5">
<Border.Effect>
<DropShadowEffect Opacity="0.4" />
</Border.Effect>
@@ -211,6 +211,9 @@
</DockPanel>
</Grid>
</TabItem>
+ <TabItem Header="SPOOLS" Margin="-100 0 0 0">
+ <local:SpoolsView/>
+ </TabItem>
</TabControl>
</Grid>
<Grid Grid.Row="1">
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 @@
+<UserControl x:Class="Tango.MachineStudio.RML.Views.SpoolsView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:vm="clr-namespace:Tango.MachineStudio.RML.ViewModels"
+ xmlns:global="clr-namespace:Tango.MachineStudio.RML"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:local="clr-namespace:Tango.MachineStudio.RML.Views"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ mc:Ignorable="d"
+ d:DesignHeight="720" d:DesignWidth="1280" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
+
+ <UserControl.Resources>
+ <converters:EmptyStringToNullConverter x:Key="EmptyStringToNullConverter" />
+ </UserControl.Resources>
+
+ <Grid>
+ <DockPanel>
+ <Border DockPanel.Dock="Top" Background="{StaticResource TransparentBackgroundBrush200}" Margin="20 0" Padding="5" CornerRadius="5">
+ <Border.Effect>
+ <DropShadowEffect Opacity="0.4" />
+ </Border.Effect>
+ <Grid>
+ <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16" Padding="2">SPOOLS</TextBlock>
+ </Grid>
+ </Border>
+
+ <Grid>
+ <DockPanel Grid.Column="1" Margin="25">
+ <Grid DockPanel.Dock="Bottom">
+ <StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 0 0">
+ <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="{StaticResource RedBrush300}" BorderBrush="{StaticResource RedBrush300}" Command="{Binding RemoveSpoolCommand}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="Delete" Width="20" Height="20" />
+ <TextBlock Margin="5 0 0 0" FontSize="16">DELETE</TextBlock>
+ </StackPanel>
+ </Button>
+ <Button Margin="0 0 0 0" MinWidth="160" Height="50" Background="{StaticResource GreenBrush300}" BorderBrush="{StaticResource GreenBrush300}" Command="{Binding AddSpoolCommand}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="Plus" Width="20" Height="20" />
+ <TextBlock Margin="5 0 0 0" FontSize="16">NEW SPOOL</TextBlock>
+ </StackPanel>
+ </Button>
+ </StackPanel>
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
+
+ </StackPanel>
+ </Grid>
+ <Grid>
+ <DataGrid Margin="0 0 0 10" SelectionUnit="FullRow" BorderBrush="{StaticResource borderBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding ActiveRML.RmlsSpools}" SelectedItem="{Binding SelectedSpool}">
+ <DataGrid.CellStyle>
+ <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
+ <Setter Property="BorderThickness" Value="0"/>
+ <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
+ <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+ </Style>
+ </DataGrid.CellStyle>
+ <DataGrid.Columns>
+ <DataGridComboBoxColumn Header="SPOOL TYPE" SelectedItemBinding="{Binding SpoolType}" DisplayMemberPath="Name" Width="Auto">
+ <DataGridComboBoxColumn.ElementStyle>
+ <Style TargetType="ComboBox">
+ <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid},Path=DataContext.SpoolTypes}"/>
+ </Style>
+ </DataGridComboBoxColumn.ElementStyle>
+ <DataGridComboBoxColumn.EditingElementStyle>
+ <Style TargetType="ComboBox">
+ <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid},Path=DataContext.SpoolTypes}"/>
+ </Style>
+ </DataGridComboBoxColumn.EditingElementStyle>
+ </DataGridComboBoxColumn>
+ <DataGridTextColumn Header="ROTATIONS PER PASSAGE" Binding="{Binding RotationsPerPassage,Converter={StaticResource EmptyStringToNullConverter}}" Width="Auto" />
+ <DataGridTextColumn Header="MAX LENGTH" Binding="{Binding Length,Converter={StaticResource EmptyStringToNullConverter}}" Width="Auto" />
+ <DataGridTextColumn Header="BACKING RATE" Binding="{Binding BackingRate,Converter={StaticResource EmptyStringToNullConverter}}" Width="Auto" />
+ <DataGridTextColumn Header="BOTTOM BACKING RATE" Binding="{Binding BottomBackingRate,Converter={StaticResource EmptyStringToNullConverter}}" Width="Auto" />
+ </DataGrid.Columns>
+ </DataGrid>
+ </Grid>
+ </DockPanel>
+ </Grid>
+ </DockPanel>
+ </Grid>
+</UserControl>
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
+{
+ /// <summary>
+ /// Interaction logic for SpoolsView.xaml
+ /// </summary>
+ public partial class SpoolsView : UserControl
+ {
+ public SpoolsView()
+ {
+ InitializeComponent();
+ }
+ }
+}