aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-10-03 14:19:04 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-10-03 14:19:04 +0300
commitc23d740d6a80db62b7b43ea17639ba4c2ef4e336 (patch)
treebc0f437f1697bd232d4dbf964a46f6d62ed2c4db /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML
parent251cf705409697f339828359b6770534116dca5f (diff)
downloadTango-c23d740d6a80db62b7b43ea17639ba4c2ef4e336.tar.gz
Tango-c23d740d6a80db62b7b43ea17639ba4c2ef4e336.zip
Working on RML Module..
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.csproj8
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/AddLiquidFactorViewVM.cs50
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/MainViewVM.cs71
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.xaml56
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.xaml.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlView.xaml13
6 files changed, 222 insertions, 4 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 99b0a3c19..b9d77e95a 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
@@ -88,7 +88,11 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="ViewModelLocator.cs" />
+ <Compile Include="ViewModels\AddLiquidFactorViewVM.cs" />
<Compile Include="ViewModels\MainViewVM.cs" />
+ <Compile Include="Views\AddLiquidFactorView.xaml.cs">
+ <DependentUpon>AddLiquidFactorView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
@@ -159,6 +163,10 @@
<Resource Include="Images\rml-module.jpg" />
</ItemGroup>
<ItemGroup>
+ <Page Include="Views\AddLiquidFactorView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Views\MainView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/AddLiquidFactorViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/AddLiquidFactorViewVM.cs
new file mode 100644
index 000000000..f6fca0ac2
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/AddLiquidFactorViewVM.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Entities;
+using Tango.SharedUI;
+using System.Data.Entity;
+
+namespace Tango.MachineStudio.RML.ViewModels
+{
+ public class AddLiquidFactorViewVM : DialogViewVM
+ {
+ private ObservablesContext _context;
+
+ private ObservableCollection<LiquidType> _liquidTypes;
+ public ObservableCollection<LiquidType> LiquidTypes
+ {
+ get
+ {
+ return _liquidTypes;
+ }
+ set
+ {
+ _liquidTypes = value; RaisePropertyChangedAuto();
+ }
+ }
+
+ private LiquidType _selectedLiquidType;
+ public LiquidType SelectedLiquidType
+ {
+ get { return _selectedLiquidType; }
+ set { _selectedLiquidType = value; RaisePropertyChangedAuto(); }
+ }
+
+ public AddLiquidFactorViewVM(ObservablesContext context)
+ {
+ _context = context;
+ }
+
+ public async override void OnShow()
+ {
+ base.OnShow();
+ LiquidTypes = (await _context.LiquidTypes.ToListAsync()).ToObservableCollection();
+ SelectedLiquidType = LiquidTypes.FirstOrDefault();
+ }
+ }
+}
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 b7e7859ac..be46e2148 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
@@ -14,6 +14,7 @@ using Tango.MachineStudio.ColorLab.ViewModels;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.RML.Contracts;
+using Tango.MachineStudio.RML.Views;
namespace Tango.MachineStudio.RML.ViewModels
{
@@ -140,6 +141,14 @@ namespace Tango.MachineStudio.RML.ViewModels
public RelayCommand AddProcessParametersTableCommand { get; set; }
+ public RelayCommand<ProcessParametersTable> RemoveProcessParametersTableCommand { get; set; }
+
+ public RelayCommand AddLiquidFactorCommand { get; set; }
+
+ public RelayCommand<LiquidTypesRml> RemoveLiquidFactorCommand { get; set; }
+
+ public RelayCommand CreateCalibrationDataExcelTemplateCommand { get; set; }
+
/// <summary>
/// Gets or sets the back to RMLS command.
/// </summary>
@@ -153,6 +162,10 @@ namespace Tango.MachineStudio.RML.ViewModels
AddRmlCommand = new RelayCommand(AddNewRml);
BackToRmlsCommand = new RelayCommand(BackToRmls);
AddProcessParametersTableCommand = new RelayCommand(AddProcessParametersTable);
+ RemoveProcessParametersTableCommand = new RelayCommand<ProcessParametersTable>(RemoveProcessParametersTable);
+ AddLiquidFactorCommand = new RelayCommand(AddLiquidFactor);
+ RemoveLiquidFactorCommand = new RelayCommand<LiquidTypesRml>(RemoveLiquidFactor);
+ CreateCalibrationDataExcelTemplateCommand = new RelayCommand(CreateCalibrationDataExcelTemplate);
}
public override void OnApplicationReady()
@@ -205,6 +218,7 @@ namespace Tango.MachineStudio.RML.ViewModels
CalibrationDataVM catVM = new CalibrationDataVM();
catVM.Name = liquidTypeRml.LiquidType.Name;
catVM.Color = liquidTypeRml.LiquidType.Color;
+ catVM.LiquidType = liquidTypeRml.LiquidType;
if (liquidTypeRml.DefaultCatData != null)
{
@@ -316,6 +330,63 @@ namespace Tango.MachineStudio.RML.ViewModels
ActiveProcessParametersTableView.Refresh();
}
+ private void RemoveLiquidFactor(LiquidTypesRml liquidFactor)
+ {
+ if (_notification.ShowQuestion("Removing this liquid factor will remove the liquid type association with the RML and will drop the calibration data. Are you sure?"))
+ {
+ var catVM = CalibrationDataViewVM.LiquidsCalibrationData.SingleOrDefault(x => x.LiquidType == liquidFactor.LiquidType);
+ CalibrationDataViewVM.LiquidsCalibrationData.Remove(catVM);
+ _active_context.LiquidTypesRmls.Remove(liquidFactor);
+ }
+ }
+
+ private void AddLiquidFactor()
+ {
+ AddLiquidFactorViewVM vm = new AddLiquidFactorViewVM(_active_context);
+ _notification.ShowModalDialog<AddLiquidFactorViewVM, AddLiquidFactorView>(vm, (_) =>
+ {
+ if (LiquidTypesRmls.ToList().Exists(x => x.LiquidType == vm.SelectedLiquidType))
+ {
+ _notification.ShowError("The selected liquid type is already associated with this RML.");
+ return;
+ }
+
+ LiquidTypesRml liquidFactor = new LiquidTypesRml()
+ {
+ LiquidType = vm.SelectedLiquidType,
+ Rml = ActiveRML,
+ };
+
+ _active_context.LiquidTypesRmls.Add(liquidFactor);
+
+ CalibrationDataVM catVM = new CalibrationDataVM();
+ catVM.Name = liquidFactor.LiquidType.Name;
+ catVM.Color = liquidFactor.LiquidType.Color;
+
+ CalibrationDataViewVM.LiquidsCalibrationData.Add(catVM);
+
+ }, () => { });
+ }
+
+ private void RemoveProcessParametersTable(ProcessParametersTable processParametersTable)
+ {
+ if (ActiveProcessParametersGroup.ProcessParametersTables.Count == 1)
+ {
+ _notification.ShowError("The process group must contain at least one table.");
+ return;
+ }
+
+ if (_notification.ShowQuestion("Are you sure you want to remove this process parameters table?"))
+ {
+ _active_context.ProcessParametersTables.Remove(processParametersTable);
+ }
+ }
+
+ private void CreateCalibrationDataExcelTemplate()
+ {
+
+ }
+
private void BackToRmls()
{
View.NavigateTo(RmlNavigationView.RmlsView);
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.xaml
new file mode 100644
index 000000000..6d9b68edb
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.xaml
@@ -0,0 +1,56 @@
+<UserControl x:Class="Tango.MachineStudio.RML.Views.AddLiquidFactorView"
+ 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:local="clr-namespace:Tango.MachineStudio.RML.Views"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:vm="clr-namespace:Tango.MachineStudio.RML.ViewModels"
+ mc:Ignorable="d"
+ d:DesignHeight="220" d:DesignWidth="600" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:AddLiquidFactorViewVM, IsDesignTimeCreatable=False}">
+
+ <UserControl.Resources>
+ <converters:ColorToIntegerConverter x:Key="ColorToIntegerConverter"></converters:ColorToIntegerConverter>
+ </UserControl.Resources>
+
+ <Grid>
+ <DockPanel LastChildFill="True">
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
+ <Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{Binding OKCommand}">
+ ACCEPT
+ </Button>
+ <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="False" Margin="0 8 8 0" Command="{Binding CloseCommand}">
+ CANCEL
+ </Button>
+ </StackPanel>
+ <Grid>
+ <StackPanel VerticalAlignment="Top" Margin="0 30 0 0">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="Plus" VerticalAlignment="Top" Width="50" Height="50" Foreground="#08B008" />
+ <TextBlock Padding="0 10 0 0" TextWrapping="Wrap" Margin="10 0 0 0" VerticalAlignment="Top" FontSize="14" Text="ADD LIQUID FACTOR" Width="400"></TextBlock>
+ </StackPanel>
+
+ <ComboBox Margin="60 0 20 0" ItemsSource="{Binding LiquidTypes}" SelectedItem="{Binding SelectedLiquidType}" SelectedIndex="0">
+ <ComboBox.ItemTemplate>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal">
+ <Rectangle Width="32" Height="32" Stroke="#2B2B2B" StrokeThickness="1">
+ <Rectangle.Fill>
+ <SolidColorBrush Color="{Binding Color,Converter={StaticResource ColorToIntegerConverter}}" />
+ </Rectangle.Fill>
+ </Rectangle>
+
+ <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">
+ <Run Text="{Binding Name}"></Run>,
+ <Run Foreground="Gray" FontSize="10">v</Run><Run Foreground="Gray" FontSize="10" Text="{Binding Version}"></Run>
+ </TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </ComboBox.ItemTemplate>
+ </ComboBox>
+ </StackPanel>
+ </Grid>
+ </DockPanel>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.xaml.cs
new file mode 100644
index 000000000..cdacddf42
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/AddLiquidFactorView.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 AddLiquidFactorView.xaml
+ /// </summary>
+ public partial class AddLiquidFactorView : UserControl
+ {
+ public AddLiquidFactorView()
+ {
+ InitializeComponent();
+ }
+ }
+}
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 e77663de4..aa6f39d9e 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
@@ -155,7 +155,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<DockPanel>
- <Button DockPanel.Dock="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" VerticalAlignment="Bottom" ToolTip="Remove table" Width="30" Margin="10 0 0 10">
+ <Button DockPanel.Dock="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" VerticalAlignment="Bottom" ToolTip="Remove table" Width="30" Margin="10 0 0 10" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RemoveProcessParametersTableCommand}" CommandParameter="{Binding}">
<materialDesign:PackIcon Kind="Delete" Width="24" Height="24" Foreground="#FF7D7D" />
</Button>
@@ -221,7 +221,7 @@
<Grid>
<TextBlock HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16">LIQUID FACTORS</TextBlock>
- <Button ToolTip="Add new liquid factor" HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" VerticalAlignment="Bottom" Width="30" Padding="0">
+ <Button ToolTip="Add new liquid factor" HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" VerticalAlignment="Bottom" Width="30" Padding="0" Command="{Binding AddLiquidFactorCommand}">
<materialDesign:PackIcon Kind="Plus" Foreground="#0AC30A" Width="24" Height="24" />
</Button>
</Grid>
@@ -234,9 +234,9 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type observables:LiquidTypesRml}">
- <Grid Margin="20 0 20 0">
+ <Grid Margin="20 0 20 0" MaxWidth="230">
- <Button HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" ToolTip="Delete liquid factor" Width="30">
+ <Button HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}" Padding="0" ToolTip="Remove liquid factor" Width="30" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.RemoveLiquidFactorCommand}" CommandParameter="{Binding}">
<materialDesign:PackIcon Kind="Delete" Foreground="#FF7D7D" />
</Button>
@@ -269,7 +269,12 @@
<Border.Effect>
<DropShadowEffect Opacity="0.4" />
</Border.Effect>
+ <Grid>
<TextBlock HorizontalAlignment="Left" Margin="20 0 0 0" FontSize="16">CALIBRATION DATA</TextBlock>
+ <Button ToolTip="Create excel file template" HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" VerticalAlignment="Bottom" Width="30" Padding="0" Command="{Binding CreateCalibrationDataExcelTemplateCommand}">
+ <materialDesign:PackIcon Kind="FileExcel" Foreground="DimGray" Width="16" Height="20" />
+ </Button>
+ </Grid>
</Border>
<colorLabViews:CalibrationDataView Margin="0 10 0 0" DataContext="{Binding CalibrationDataViewVM}" />