diff options
| author | Roy <Roy.mail.net@gmail.com> | 2023-09-03 16:18:55 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2023-09-03 16:18:55 +0300 |
| commit | c66acc359b311ecc940f3c4e74bd9e21dc0bfd51 (patch) | |
| tree | 8869b9d48fbad776c94df401680afc43fc350e69 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 6cdea71fa07d092139697d9c67651dade37aed96 (diff) | |
| parent | b271fe1c21172ed22a34b987a2cb9457b39ce8a3 (diff) | |
| download | Tango-c66acc359b311ecc940f3c4e74bd9e21dc0bfd51.tar.gz Tango-c66acc359b311ecc940f3c4e74bd9e21dc0bfd51.zip | |
Merged Eureka Branch !!!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
12 files changed, 212 insertions, 54 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 47fe19a05..ab86d8356 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -19,6 +19,7 @@ using System.IO; using Tango.BL.ActionLogs; using Tango.MachineStudio.Common.Authentication; using Tango.BL.DTO; +using Tango.BL.Enumerations; namespace Tango.MachineStudio.HardwareDesigner.ViewModels { @@ -445,6 +446,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels await Task.Factory.StartNew(() => { CurrentVersion.LastUpdated = DateTime.UtcNow; + CurrentVersion.UserName = _authentication.CurrentUser.Email; + _db.SaveChanges(); var dtoAfter = HardwareVersionDTO.FromObservable(CurrentVersion); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml index 9ee2ffee7..134d5d455 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml @@ -14,13 +14,14 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.HardwareDesigner.ViewModels" xmlns:observables="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:global="clr-namespace:Tango.MachineStudio.HardwareDesigner" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" mc:Ignorable="d" d:DesignHeight="2000" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> <UserControl.Resources> <converters:DoubleToIntConverter x:Key="DoubleToIntConverter" /> <converters:NullObjectToBooleanConverter x:Key="NullObjectToBooleanConverter" /> - + <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> <Style TargetType="ListBox" x:Key="typesList" BasedOn="{StaticResource {x:Type ListBox}}"> <Setter Property="FontSize" Value="14"></Setter> <Setter Property="ItemContainerStyle"> @@ -58,10 +59,11 @@ <TextBlock FontSize="30" FontStyle="Italic" VerticalAlignment="Center" Margin="50 10 10 0" Foreground="Silver" FontWeight="Bold">HARDWARE DESIGNER</TextBlock> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10 10 0 0"> <materialDesign:PackIcon Kind="Pencil" Width="32" Height="32" Foreground="Silver" /> - <controls:SearchComboBox IsEnabled="{Binding IsFree}" ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedVersion}" Width="300" SearchProperty="FullName" FontSize="16" FontWeight="Bold" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Hardware Version"> + + <controls:SearchComboBox IsEnabled="{Binding IsFree}" ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedVersion}" Width="400" SearchProperty="FullName" FontSize="16" FontWeight="Bold" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Hardware Version"> <ComboBox.ItemTemplate> <DataTemplate> - <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14">v</Run><Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14" Text="{Binding Version}"></Run></TextBlock> + <TextBlock><Run Text="{Binding Name}"></Run> <Run></Run> <Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14">v</Run><Run Foreground="{StaticResource MainWindow.Foreground}" FontSize="14" Text="{Binding Version}"></Run> <Run Foreground="{StaticResource AccentColorBrush}" FontSize="14" Text="{Binding ForMachineType}"></Run></TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </controls:SearchComboBox> @@ -385,8 +387,12 @@ <TextBlock Margin="0 10 0 0" FontSize="10" Foreground="{StaticResource GrayBrush}">Name</TextBlock> <TextBox Text="{Binding CurrentVersion.Name,UpdateSourceTrigger=PropertyChanged}"></TextBox> + <TextBlock Margin="0 20 0 0" FontSize="10" Foreground="{StaticResource GrayBrush}">Machine Type</TextBlock> + <ComboBox ItemsSource="{Binding Source={x:Type enumerations:MachineTypes},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding CurrentVersion.ForMachineType,Mode=TwoWay}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"/> + <TextBlock Margin="0 20 0 0" FontSize="10" Foreground="{StaticResource GrayBrush}">Version</TextBlock> <mahApps:NumericUpDown Minimum="0" BorderThickness="0 0 0 1" HorizontalContentAlignment="Left" Maximum="1000" HasDecimals="True" Value="{Binding CurrentVersion.Version}" Foreground="{StaticResource GrayBrush}"/> + </StackPanel> </materialDesign:Card> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs index 8a2f5dd9f..38430e197 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Models/MachineModel.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.Core; namespace Tango.MachineStudio.MachineDesigner.Models @@ -12,6 +13,8 @@ namespace Tango.MachineStudio.MachineDesigner.Models { public String Guid { get; set; } + public MachineTypes MachineType { get; set; } + public String SerialNumber { get; set; } public String Name { get; set; } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs index 168ff62dd..9d203b76d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MachineCreationDialogVM.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.SharedUI; namespace Tango.MachineStudio.MachineDesigner.ViewModels @@ -14,9 +15,24 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels public List<HardwareVersion> HardwareVersions { get; set; } - public HardwareVersion SelectedHardwareVersion { get; set; } + public List<HardwareVersion> HardwareVersionsFiltered + { + get { return HardwareVersions.Where(x => x.MachineType == (int)MachineType).ToList(); } + } + + private HardwareVersion _selectedHardwareVersion; + public HardwareVersion SelectedHardwareVersion + { + get { return _selectedHardwareVersion; } + set { _selectedHardwareVersion = value; RaisePropertyChangedAuto(); } + } - public MachinePrototype SelectedPrototype { get; set; } + private MachinePrototype _selectedProtoType; + public MachinePrototype SelectedPrototype + { + get { return _selectedProtoType; } + set { _selectedProtoType = value; MachineType = (MachineTypes)value.MachineType; } + } private bool _isNewMachine; public bool IsNewMachine @@ -32,6 +48,13 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels set { _serialNumber = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private MachineTypes _machineType; + public MachineTypes MachineType + { + get { return _machineType; } + set { _machineType = value; RaisePropertyChanged(nameof(HardwareVersionsFiltered)); SelectedHardwareVersion = HardwareVersionsFiltered.FirstOrDefault(); } + } + private String _name; public String Name { @@ -41,7 +64,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels protected override bool CanOK() { - return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name); + return base.CanOK() && !String.IsNullOrWhiteSpace(SerialNumber) && !String.IsNullOrWhiteSpace(Name) && SelectedHardwareVersion != null; } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs index c31ea0a53..cad54c848 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs @@ -540,6 +540,8 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels ActiveMachine.Configuration = new Configuration(); ActiveMachine.SerialNumber = machineCreationDialogVM.SerialNumber; ActiveMachine.Name = machineCreationDialogVM.Name; + ActiveMachine.Type = machineCreationDialogVM.MachineType; + ActiveMachine.MachineVersion = ActiveMachineAdapter.MachineVersions.First(x => x.MachineType == machineCreationDialogVM.MachineType); ActiveMachineAdapter.Context.Machines.Add(ActiveMachine); } else @@ -548,7 +550,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { initHwConfig = false; ActiveMachine = machineCreationDialogVM.SelectedPrototype.CreateMachine(machineCreationDialogVM.SerialNumber, machineCreationDialogVM.Name); - ActiveMachine.MachineVersion = ActiveMachineAdapter.MachineVersions.FirstOrDefault(x => x.Guid == ActiveMachine.MachineVersionGuid); + ActiveMachine.MachineVersion = ActiveMachineAdapter.MachineVersions.First(x => x.MachineType == machineCreationDialogVM.MachineType); if (machineCreationDialogVM.SelectedHardwareVersion != null) { @@ -713,6 +715,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels errors.Add("Hardware version is required."); } + if (ActiveMachine.Configuration.HardwareVersion != null) + { + if (ActiveMachine.Configuration.HardwareVersion.ForMachineType != ActiveMachine.Type) + { + errors.Add($"Hardware version '{ActiveMachine.Configuration.HardwareVersion.Name}' is intended only for {ActiveMachine.Configuration.HardwareVersion.ForMachineType} machines."); + } + } + foreach (var pack in ActiveMachine.Configuration.IdsPacks) { if (pack.LiquidType != null || pack.CartridgeType != null || pack.Dispenser != null || pack.IdsPackFormula != null || pack.MidTankType != null) @@ -853,7 +863,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels vm.IsNewMachine = true; vm.Prototypes = prototypes.ToList(); vm.HardwareVersions = hardwareVersions.OrderByDescending(x => x.Version).ToList(); - vm.SelectedHardwareVersion = vm.HardwareVersions.FirstOrDefault(); + vm.SelectedHardwareVersion = vm.HardwareVersions.Where(x => x.ForMachineType == MachineTypes.TS1800).FirstOrDefault(); _notification.ShowModalDialog<MachineCreationDialogVM, Views.MachineCreationDialog>(vm, (x) => { using (ObservablesContext db = ObservablesContext.CreateDefault()) @@ -1013,6 +1023,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { x.Guid, x.SerialNumber, + x.MachineType, x.Name, Organization = x.Organization.Name, MachineVersion = x.MachineVersion.Name, @@ -1030,6 +1041,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels MachineModel model = new MachineModel(); model.Guid = machine.Guid; model.SerialNumber = machine.SerialNumber; + model.MachineType = (MachineTypes)machine.MachineType; model.Name = machine.Name; model.Organization = machine.Organization; model.HardwareVersion = machine.HardwareVersionName + " v" + machine.HardwareVersionVersion; diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml index 8b3851036..8a4a9161b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineCreationDialog.xaml @@ -8,11 +8,14 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="700" Height="460" Width="750" Background="{StaticResource Dialog.Background}" d:DataContext="{d:DesignInstance Type=vm:MachineCreationDialogVM, IsDesignTimeCreatable=False}" Foreground="{StaticResource Dialog.Foreground}"> <UserControl.Resources> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></converters:BooleanToVisibilityConverter> + <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter" /> + <converters:IsNullToVisibilityInverseConverter x:Key="IsNullToVisibilityInverseConverter" /> </UserControl.Resources> <Grid Margin="10"> @@ -20,7 +23,7 @@ <Grid DockPanel.Dock="Top"> <StackPanel Orientation="Horizontal"> <Grid> - <Image Source="../Images/machine-full-fx.png" Width="120" RenderOptions.BitmapScalingMode="Fant"></Image> + <Image Source="{StaticResource Machines}" Width="120" RenderOptions.BitmapScalingMode="Fant"></Image> <materialDesign:PackIcon HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 -10 -10" Kind="PlusCircle" Foreground="#15C315" Width="42" Height="42" /> </Grid> <TextBlock Margin="30 0 0 0" VerticalAlignment="Bottom" FontSize="22"> @@ -52,11 +55,16 @@ <Grid> <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20 20 0 0" Width="400"> <TextBlock TextWrapping="Wrap" Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}"> - <Run>Specify a machine prototype to create the new machine with default settings and configuration.</Run> + <Run>Specify a machine prototype and machine type to create the new machine with default settings and configuration.</Run> </TextBlock> - <ComboBox Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}" ItemsSource="{Binding Prototypes}" SelectedItem="{Binding SelectedPrototype}" DisplayMemberPath="Name" Margin="0 10 0 0" FontSize="16" materialDesign:HintAssist.Hint="NONE"></ComboBox> - + <DockPanel Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0 10 0 0"> + <ComboBox x:Name="comboProto" Width="200" ItemsSource="{Binding Prototypes}" SelectedItem="{Binding SelectedPrototype}" DisplayMemberPath="Name" FontSize="16" materialDesign:HintAssist.Hint="NONE"></ComboBox> + <ComboBox Visibility="{Binding ElementName=comboProto,Path=SelectedItem,Converter={StaticResource IsNullToVisibilityInverseConverter}}" Margin="30 0 0 0" ItemsSource="{Binding Source={x:Type enumerations:MachineTypes},Converter={StaticResource EnumToItemsSourceConverter}}" FontSize="16" SelectedValue="{Binding MachineType,Mode=TwoWay}" SelectedValuePath="Value" DisplayMemberPath="DisplayName"> + + </ComboBox> + </DockPanel> + <TextBlock Margin="0 20 0 0" FontSize="10">Serial Number</TextBlock> <TextBox Margin="0 2 0 0" Text="{Binding SerialNumber,UpdateSourceTrigger=PropertyChanged}"></TextBox> @@ -65,7 +73,7 @@ <StackPanel Margin="0 20 0 0" Visibility="{Binding IsNewMachine,Converter={StaticResource BooleanToVisibilityConverter}}"> <TextBlock FontSize="10">Hardware Version</TextBlock> - <ComboBox Margin="0 2 0 0" ItemsSource="{Binding HardwareVersions}" SelectedItem="{Binding SelectedHardwareVersion}" DisplayMemberPath="FullName"></ComboBox> + <ComboBox Margin="0 2 0 0" ItemsSource="{Binding HardwareVersionsFiltered}" SelectedItem="{Binding SelectedHardwareVersion}" DisplayMemberPath="FullName"></ComboBox> </StackPanel> </StackPanel> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml index 4ba79d3f5..852e60d0f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineSettingsView.xaml @@ -54,7 +54,7 @@ <ComboBox ItemsSource="{Binding Source={x:Type enumerations:HeadTypes},Converter={StaticResource EnumToItemsSourceConverter}}" SelectedValue="{Binding ActiveMachine.MachineHeadType}" SelectedValuePath="Value" DisplayMemberPath="DisplayName" Style="{StaticResource TransparentComboBoxStyle}"></ComboBox> <TextBlock FontWeight="SemiBold">Machine Version</TextBlock> - <ComboBox Background="Transparent" ItemsSource="{Binding ActiveMachineAdapter.MachineVersions}" SelectedItem="{Binding ActiveMachine.MachineVersion}" DisplayMemberPath="Name" Style="{StaticResource TransparentComboBoxStyle}" ></ComboBox> + <ComboBox IsEnabled="False" Background="Transparent" ItemsSource="{Binding ActiveMachineAdapter.MachineVersions}" SelectedItem="{Binding ActiveMachine.MachineVersion}" DisplayMemberPath="Name" Style="{StaticResource TransparentComboBoxStyle}" ></ComboBox> <TextBlock FontWeight="SemiBold">Version Tag</TextBlock> <ComboBox Background="Transparent" ItemsSource="{Binding Tags}" SelectedItem="{Binding ActiveMachine.VersionTag}" Style="{StaticResource TransparentComboBoxStyle}" ></ComboBox> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml index 5fda6dbfa..3c73ecc2b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml @@ -22,7 +22,7 @@ <DockPanel Margin="100" MaxWidth="1200"> <Grid DockPanel.Dock="Top"> <StackPanel Orientation="Horizontal"> - <Image Source="../Images/machine-full-fx.png" Width="350" RenderOptions.BitmapScalingMode="Fant" Margin="10" /> + <Image Source="{StaticResource Machines}" Width="350" RenderOptions.BitmapScalingMode="Fant" Margin="10" /> <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" Margin="0 0 0 10"> <materialDesign:PackIcon VerticalAlignment="Center" Kind="BarcodeScan" Width="32" Height="32" /> @@ -70,6 +70,7 @@ </Style> </DataGrid.CellStyle> <DataGrid.Columns> + <DataGridTextColumn Header="TYPE" Binding="{Binding MachineType}" Width="Auto" /> <DataGridTextColumn Header="SERIAL NUMBER" Binding="{Binding SerialNumber}" Width="Auto" /> <DataGridTextColumn Header="NAME" Binding="{Binding Name}" Width="Auto" /> <DataGridTextColumn Header="ORGANIZATION" Binding="{Binding Organization}" Width="Auto" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs index b1be35a38..dce3432e2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Models/RmlModel.cs @@ -11,10 +11,16 @@ namespace Tango.MachineStudio.RML.Models { public class RmlModel : ExtendedObject { + public class LiquidTypeColorValue + { + public int Color { get; set; } + + public double LiquidTypeValue { get; set; } + } public String Guid { get; set; } public String Name { get; set; } - + public String DisplayName { get; set; } public String CCT { get; set; } @@ -27,8 +33,23 @@ namespace Tango.MachineStudio.RML.Models public String Btsr { get; set; } + public String DyeingSpeed { get; set; } + + public String Zone1InkUptake { get; set; } + + public String Zone2InkUptake { get; set; } + public DateTime LastUpdated { get; set; } public List<int> LiquidTypes { get; set; } + + public List<LiquidTypeColorValue> LiquidTypesR { get; set; } + + public RmlModel() + { + DyeingSpeed = "-"; + Zone1InkUptake = "-"; + Zone2InkUptake = "-"; + } } } 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 fd276ea65..7eb6e9058 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 @@ -28,6 +28,7 @@ using Tango.BL.Enumerations; using Google.Protobuf; using Tango.ColorConversion; using Tango.CSV; +using Tango.Core; namespace Tango.MachineStudio.RML.ViewModels { @@ -345,18 +346,21 @@ namespace Tango.MachineStudio.RML.ViewModels private async Task LoadRmls() { var filter = RMLFilter.ToStringOrEmpty().ToLower(); - + using (ObservablesContext db = ObservablesContext.CreateDefault()) { + var rmls = await db.Rmls.Where(x => x.Name.ToLower().Contains(filter) || x.DisplayName.ToLower().Contains(filter)) .Include(x => x.Cct.FileName) + .Include(x => x.LiquidTypesRmls) .Include(x => x.LiquidTypesRmls.Select(y => y.LiquidType)) .Include(x => x.BtsrApplicationType.Name) .Include(x => x.BtsrYarnType.Name) + .Include(x => x.ProcessParametersTablesGroups) .Select(x => new { - x.Guid, x.Name, + x.Guid, x.DisplayName, x.Cct.FileName, x.ColorConversionVersion, @@ -366,13 +370,44 @@ namespace Tango.MachineStudio.RML.ViewModels x.LastUpdated, BtsrApplicationType = x.BtsrApplicationType != null ? x.BtsrApplicationType.Name : String.Empty, BtsrYarnType = x.BtsrYarnType != null ? x.BtsrYarnType.Name : String.Empty, - LiquidTypes = x.LiquidTypesRmls.Select(y => y.LiquidType) + LiquidTypesRmls = x.LiquidTypesRmls, + LiquidTypes = x.LiquidTypesRmls.Select(y => y.LiquidType), + ProcessParametersTables = x.ProcessParametersTablesGroups }).ToListAsync(); + List<RmlModel> models = new List<RmlModel>(); + //var tables = ActiveRML.GetActiveProcessGroup().ProcessParametersTables; + foreach (var rml in rmls.OrderBy(x => x.Name).ToList()) { + ProcessParametersTable tableZone1 = null; + ProcessParametersTable tableZone2 = null; + if (rml.ProcessParametersTables != null) + { + var activeTablesGroup = rml.ProcessParametersTables.Where(x=>x.Active).FirstOrDefault(); + if ( activeTablesGroup != null) + { + try + { + var tables = await db.ProcessParametersTables.Where(x => x.ProcessParametersTablesGroupGuid == activeTablesGroup.Guid).OrderBy(x => x.TableIndex).ToListAsync(); + if (tables.Count > 0) + { + tableZone1 = tables[0]; + } + if (tables.Count > 1) + { + tableZone2 = tables[1]; + } + } + catch (Exception ex) + { + LogManager.Log($"Error loading ProcessParametersTables {ex.Message}"); + } + }; + } + RmlModel model = new RmlModel(); model.Guid = rml.Guid; model.Name = rml.Name; @@ -383,8 +418,21 @@ namespace Tango.MachineStudio.RML.ViewModels model.UseLightInks = rml.UseLightInks; model.HeadType = (HeadTypes)rml.HeadType; model.Btsr = (String.IsNullOrEmpty(rml.BtsrApplicationType) ? "N/A" : rml.BtsrApplicationType) + ", " + (String.IsNullOrEmpty(rml.BtsrYarnType) ? "N/A" : rml.BtsrYarnType); - model.LiquidTypes = rml.LiquidTypes.OrderBy(x => x.Code).Select(x => x.Color).ToList(); + + if( tableZone1 != null) + { + model.Zone1InkUptake = String.Format($"{tableZone1.MinInkUptake}-{tableZone1.MaxInkUptake}"); + model.DyeingSpeed = tableZone1.DyeingSpeed.ToString(); + } + if(tableZone2 != null) + { + model.DyeingSpeed += String.Format($"-{tableZone2.DyeingSpeed}"); + model.Zone2InkUptake = tableZone2 == null ? "-" : String.Format($"{tableZone2.MinInkUptake}-{tableZone2.MaxInkUptake}"); + } + model.LiquidTypes = rml.LiquidTypes.OrderBy(x => x.Code).Select(x => x.Color).ToList(); + model.LiquidTypesR = rml.LiquidTypesRmls.OrderBy(x => x.LiquidType.Code).ToList().Select((n) => new RmlModel.LiquidTypeColorValue(){ Color = n.LiquidType.Color, LiquidTypeValue = n.MaxNlPerCm }).ToList(); + models.Add(model); } @@ -482,6 +530,11 @@ namespace Tango.MachineStudio.RML.ViewModels } ActiveProcessParametersGroup = ActiveRML.ProcessParametersTablesGroups.ToList().FirstOrDefault(); + + var tables= ActiveRML.ProcessParametersTablesGroups.ToList(); + var zone1 = tables[0].ProcessParametersTables; + /* + * */ ActiveProcessParametersTableView = CollectionViewSource.GetDefaultView(ActiveProcessParametersGroup.ProcessParametersTables); ActiveProcessParametersTableView.SortDescriptions.Add(new SortDescription(nameof(ProcessParametersTable.TableIndex), ListSortDirection.Ascending)); @@ -1075,10 +1128,10 @@ namespace Tango.MachineStudio.RML.ViewModels } } - private void BackToRmls() + private async void BackToRmls() { View.NavigateTo(RmlNavigationView.RmlsView); - LoadRmls(); + await LoadRmls(); } #region Batch Conversion 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 08af47ef4..8730355cc 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 @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:global="clr-namespace:Tango.MachineStudio.RML" xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:observables="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" @@ -21,6 +22,14 @@ <UserControl.Resources> <converters:ColorToIntegerConverter x:Key="ColorToIntegerConverter"></converters:ColorToIntegerConverter> <converters:EnumToItemsSourceConverter x:Key="EnumToItemsSourceConverter"/> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"/> + + <ObjectDataProvider x:Key="Plies" ObjectType="{x:Type sys:Enum}" MethodName="GetValues"> + <ObjectDataProvider.MethodParameters> + <x:Type TypeName="enumerations:Plies"/> + </ObjectDataProvider.MethodParameters> + </ObjectDataProvider> + </UserControl.Resources> <Grid Margin="20"> @@ -94,45 +103,60 @@ <ComboBox ItemsSource="{Binding Purposes}" SelectedItem="{Binding ActiveRML.MediaPurpose,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> <TextBlock Text="Condition:" ></TextBlock> - <ComboBox ItemsSource="{Binding Conditions}" SelectedItem="{Binding ActiveRML.MediaCondition,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> + <ComboBox ItemsSource="{Binding Conditions}" SelectedItem="{Binding ActiveRML.MediaCondition,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox>--> + + + <TextBlock Text="Linear Density:" ></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="9999" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.FiberSize,Mode=TwoWay}" FontSize="16"></mahapps:NumericUpDown> - <TextBlock Text="Linear Mass Density Unit:" ></TextBlock> + <TextBlock Text="Linear Density Unit:" ></TextBlock> <ComboBox ItemsSource="{Binding LinearMassDensityUnits}" SelectedItem="{Binding ActiveRML.LinearMassDensityUnit,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> - <TextBlock Text="Fiber Shape:" ></TextBlock> - <ComboBox ItemsSource="{Binding FiberShapes}" SelectedItem="{Binding ActiveRML.FiberShape,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> + <TextBlock Text="Plies:" ></TextBlock> + <ComboBox ItemsSource="{Binding Source={StaticResource Plies}}" SelectedItem="{Binding ActiveRML.RMLPlies, Mode=TwoWay}" > + <ComboBox.ItemTemplate> + <DataTemplate> + <TextBlock Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + + <TextBlock Text="Count (den):" ></TextBlock> + <TextBlock Text="{Binding ActiveRML.DencityCount}" Foreground="Blue" ></TextBlock> - <TextBlock Text="Fiber Syntheses:" ></TextBlock> - <ComboBox ItemsSource="{Binding FiberSynths}" SelectedItem="{Binding ActiveRML.FiberSynth,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox> + + <!--<TextBlock Text="Fiber Shape:" ></TextBlock> + <ComboBox ItemsSource="{Binding FiberShapes}" SelectedItem="{Binding ActiveRML.FiberShape,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox>--> - <TextBlock Text="Fiber Size:" ></TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.FiberSize,Mode=TwoWay}"></mahapps:NumericUpDown> + <!--<TextBlock Text="Fiber Syntheses:" ></TextBlock> + <ComboBox ItemsSource="{Binding FiberSynths}" SelectedItem="{Binding ActiveRML.FiberSynth,Mode=TwoWay}" DisplayMemberPath="Name"></ComboBox>--> - <TextBlock Text="Fibers Count:" ></TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.NumberOfFibers,Mode=TwoWay}"></mahapps:NumericUpDown> + <!--<TextBlock Text="Fiber Size:" ></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.FiberSize,Mode=TwoWay}"></mahapps:NumericUpDown>--> - <TextBlock Text="Plies Per Fiber:" ></TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.PliesPerFiber,Mode=TwoWay}"></mahapps:NumericUpDown> + <!--<TextBlock Text="Fibers Count:" ></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.NumberOfFibers,Mode=TwoWay}"></mahapps:NumericUpDown>--> - <TextBlock Text="Plies Per Thread:" ></TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.PliesPerThread,Mode=TwoWay}"></mahapps:NumericUpDown> + <!--<TextBlock Text="Plies Per Thread:" ></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.PliesPerThread,Mode=TwoWay}"></mahapps:NumericUpDown>--> + - <TextBlock Text="Tensile Strength:" ></TextBlock> + <!--<TextBlock Text="Tensile Strength:" ></TextBlock> <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.TensileStrength,Mode=TwoWay}"></mahapps:NumericUpDown> <TextBlock Text="Elongation Break Percentage:" ></TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.ElongationAtBreakPercentage,Mode=TwoWay}"></mahapps:NumericUpDown> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.ElongationAtBreakPercentage,Mode=TwoWay}"></mahapps:NumericUpDown>--> - <TextBlock Text="Estimated Thread Diameter:" ></TextBlock> - <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.EstimatedThreadDiameter,Mode=TwoWay}"></mahapps:NumericUpDown> + <!--<TextBlock Text="Estimated Thread Diameter:" ></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.EstimatedThreadDiameter,Mode=TwoWay}"></mahapps:NumericUpDown>--> - <TextBlock Text="Twisted:" ></TextBlock> + <!--<TextBlock Text="Twisted:" ></TextBlock> <ToggleButton HorizontalAlignment="Right" IsChecked="{Binding ActiveRML.Twisted}" Style="{StaticResource MaterialDesignSwitchToggleButton}" /> <TextBlock Text="Air Entanglement:" ></TextBlock> - <ToggleButton HorizontalAlignment="Right" IsChecked="{Binding ActiveRML.AirEntanglement}" Style="{StaticResource MaterialDesignSwitchToggleButton}" /> + <ToggleButton HorizontalAlignment="Right" IsChecked="{Binding ActiveRML.AirEntanglement}" Style="{StaticResource MaterialDesignSwitchToggleButton}" />--> - <TextBlock Text="Lubricant:" ></TextBlock> + <!--<TextBlock Text="Lubricant:" ></TextBlock> <ToggleButton HorizontalAlignment="Right" IsChecked="{Binding ActiveRML.Lubricant}" Style="{StaticResource MaterialDesignSwitchToggleButton}" />--> </controls:TableGrid> </DockPanel> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml index d5f4165c9..9c684c052 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/Views/RmlsView.xaml @@ -81,7 +81,7 @@ </StackPanel> </Grid> <Grid> - <DataGrid Margin="0 0 0 10" BorderBrush="Silver" IsReadOnly="True" BorderThickness="1" SelectionUnit="FullRow" RowHeight="60" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRML}" HorizontalScrollBarVisibility="Disabled"> + <DataGrid Margin="0 0 0 10" BorderBrush="Silver" IsReadOnly="True" BorderThickness="1" SelectionUnit="FullRow" RowHeight="60" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRML}" HorizontalScrollBarVisibility="Disabled" EnableRowVirtualization="False"> <DataGrid.CellStyle> <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> <Setter Property="BorderThickness" Value="0"/> @@ -90,31 +90,34 @@ </Style> </DataGrid.CellStyle> <DataGrid.Columns> - <DataGridTemplateColumn Header="NAME" Width="200"> + <DataGridTemplateColumn Header="NAME" Width="220"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel> - <TextBlock Text="{Binding Name}"></TextBlock> - <TextBlock Visibility="{Binding DisplayName,Converter={StaticResource IsNullToVisibilityConverter}}" FontSize="11" Foreground="{StaticResource GrayBrush}" Margin="2 2 0 0"> + <TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis"></TextBlock> + <TextBlock Visibility="{Binding DisplayName,Converter={StaticResource IsNullToVisibilityConverter}}" FontSize="11" Foreground="{StaticResource GrayBrush}" Margin="2 2 0 0" TextTrimming="CharacterEllipsis"> <Run>(</Run><Run Text="{Binding DisplayName,Mode=OneWay}"></Run><Run>)</Run> </TextBlock> </StackPanel> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> - <DataGridTextColumn Header="HEAD" Binding="{Binding HeadType}" Width="Auto" /> - <DataGridTextColumn Header="BTSR" Binding="{Binding Btsr}" Width="Auto" /> + <DataGridTextColumn Header="Dyeing speed" Width="Auto" Binding="{Binding DyeingSpeed}"></DataGridTextColumn> + <DataGridTextColumn Header="Zone1 ink uptake" Width="Auto" Binding="{Binding Zone1InkUptake}"></DataGridTextColumn> + <DataGridTextColumn Header="Zone2 ink uptake" Width="Auto" Binding="{Binding Zone2InkUptake}"></DataGridTextColumn> + <!--<DataGridTextColumn Header="HEAD" Binding="{Binding HeadType}" Width="Auto" />--> + <!--<DataGridTextColumn Header="BTSR" Binding="{Binding Btsr}" Width="Auto" />--> <DataGridTextColumn Header="CCT" Binding="{Binding CCT}" Width="Auto" /> - <DataGridTextColumn Header="CL GR" Binding="{Binding UseGradients,Converter={StaticResource BooleanToYesNoConverter}}" Width="Auto" /> - <DataGridTextColumn Header="LIGHT INKS" Binding="{Binding UseLightInks,Converter={StaticResource BooleanToYesNoConverter}}" Width="Auto" /> + <!--<DataGridTextColumn Header="CL GR" Binding="{Binding UseGradients,Converter={StaticResource BooleanToYesNoConverter}}" Width="Auto" />--> + <!--<DataGridTextColumn Header="LIGHT INKS" Binding="{Binding UseLightInks,Converter={StaticResource BooleanToYesNoConverter}}" Width="Auto" />--> <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" /> <DataGridTemplateColumn Header="LIQUID FACTORS" Width="1*"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> - <ItemsControl ItemsSource="{Binding LiquidTypes}" Margin="0 -5 0 0"> + <ItemsControl ItemsSource="{Binding LiquidTypesR}" Margin="0 -5 0 0"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> - <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" IsItemsHost="True"></StackPanel> + <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" IsItemsHost="True" ></StackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> @@ -123,11 +126,12 @@ <shapes:Hexagon StrokeThickness="1" Stroke="Gray"> <shapes:Hexagon.Fill> <LinearGradientBrush Opacity="0.7" > - <GradientStop Color="{Binding Converter={StaticResource ColorToIntegerConverter}}"/> + <GradientStop Color="{Binding Color, Converter={StaticResource ColorToIntegerConverter}}"/> <GradientStop Color="White" Offset="1"/> </LinearGradientBrush> </shapes:Hexagon.Fill> </shapes:Hexagon> + <TextBlock Text="{Binding LiquidTypeValue, TargetNullValue=0}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="9"></TextBlock> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> |
