diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-04-24 13:46:46 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-04-24 13:46:46 +0300 |
| commit | 9f900ab8d1c25e8c62ded7b56cd3991d4cd14248 (patch) | |
| tree | 54fe3b39e2a4bd765daa407202cd22e2c1f5ae6d /Software/Visual_Studio/PPC | |
| parent | badb781019975dae252b6f48c757897c4f07b150 (diff) | |
| download | Tango-9f900ab8d1c25e8c62ded7b56cd3991d4cd14248.tar.gz Tango-9f900ab8d1c25e8c62ded7b56cd3991d4cd14248.zip | |
InkLevels converters. Bug in progress bar.
Diffstat (limited to 'Software/Visual_Studio/PPC')
4 files changed, 134 insertions, 7 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs new file mode 100644 index 000000000..8e419b6fd --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs @@ -0,0 +1,71 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using Tango.BL.Entities; +using Tango.SharedUI.Helpers; + +namespace Tango.PPC.UI.Converters +{ + public class LiquidTypeToBrushConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is LiquidType) + { + LiquidType type = value as LiquidType; + switch (type.Type) + { + case BL.Enumerations.LiquidTypes.Lubricant: + { + + ImageBrush lubricantBrush = new ImageBrush() { Stretch = Stretch.None, TileMode = TileMode.Tile, ViewportUnits = BrushMappingMode.Absolute }; + + BitmapSource bit_source = ResourceHelper.GetImageFromResources(@"Images/lubricant2.png"); + var targetBitmap = new WriteableBitmap(new TransformedBitmap(bit_source, new ScaleTransform(0.2, 0.2))); + lubricantBrush.ImageSource = targetBitmap; + lubricantBrush.Viewport = new System.Windows.Rect(2, 2, targetBitmap.Width, targetBitmap.Height); + return lubricantBrush; + } + case BL.Enumerations.LiquidTypes.Cleaner: + { + ImageBrush cleanerBrush = new ImageBrush() { Stretch = Stretch.None, TileMode = TileMode.Tile, ViewportUnits = BrushMappingMode.Absolute }; + BitmapSource bit_source = ResourceHelper.GetImageFromResources(@"Images/cl-full.png"); + var targetBitmap = new WriteableBitmap(new TransformedBitmap(bit_source, new ScaleTransform(0.3, 0.3))); + + cleanerBrush.ImageSource = targetBitmap; + cleanerBrush.Viewport = new System.Windows.Rect(0, 0, targetBitmap.Width, targetBitmap.Height); + return cleanerBrush; + } + case BL.Enumerations.LiquidTypes.Yellow: + return Application.Current.Resources["TangoYellowInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Cyan: + return Application.Current.Resources["TangoCyanInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.Magenta: + return Application.Current.Resources["TangoMagentaInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.LightCyan: + return Application.Current.Resources["TangoLightCyanInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.LightMagenta: + return Application.Current.Resources["TangoLightMagentaInkBrush"] as Brush; + case BL.Enumerations.LiquidTypes.LightYellow: + return Application.Current.Resources["TangoLightYellowInkBrush"] as Brush; + } + + + return new SolidColorBrush(type.LiquidTypeColor); + } + return null; + + } + + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/MidTankLevelToElementRectConverter.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/MidTankLevelToElementRectConverter.cs new file mode 100644 index 000000000..b82ed2b52 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/MidTankLevelToElementRectConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.Integration.Operation; + +namespace Tango.PPC.UI.Converters +{ + public class MidTankLevelToElementRectConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + try + { + double actualHeight = (double)values[0]; + double actualWidth = (double)values[1]; + double midTankLevel = Math.Min((double)values[2], MachineOperator.MAX_MIDTANK_LITERS); + + var offset = (midTankLevel / MachineOperator.MAX_MIDTANK_LITERS) * actualHeight; + return new System.Windows.Rect(1, offset, actualWidth, actualHeight); + } + catch + { + return 0d; + } + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index bb67015e9..7266a0d10 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -145,6 +145,8 @@ <Compile Include="Converters\ItemBaseConverter.cs" /> <Compile Include="Converters\LengthToWeightConverter.cs" /> <Compile Include="Converters\LengthWithSpoolsConverter.cs" /> + <Compile Include="Converters\LiquidTypeToBrushConverter.cs" /> + <Compile Include="Converters\MidTankLevelToElementRectConverter.cs" /> <Compile Include="Converters\ProgressLengthSpoolConverter.cs" /> <Compile Include="Converters\ProgressWeightSpoolConverter.cs" /> <Compile Include="Dialogs\BitResultsView.xaml.cs"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml index 49e18edf5..234af2312 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/MachineStatusView.xaml @@ -3,6 +3,7 @@ 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:sys="clr-namespace:System;assembly=mscorlib" xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:vm="clr-namespace:Tango.PPC.UI.ViewModels" @@ -20,6 +21,8 @@ <localConverters:CollectionToCountConverter x:Key="CollectionToCountConverter"/> <localConverters:ProgressLengthSpoolConverter x:Key="ProgressLengthSpoolConverter"/> <localConverters:ProgressWeightSpoolConverter x:Key="ProgressWeightSpoolConverter"/> + <localConverters:LiquidTypeToBrushConverter x:Key="LiquidTypeToBrushConverter"/> + <localConverters:MidTankLevelToElementRectConverter x:Key="MidTankLevelToElementRectConverter"/> <Style x:Key="LinkRoundButtonStyle" TargetType="{x:Type touch:TouchButton}"> <Setter Property="Background" Value="{StaticResource TangoMidAccentBrush}"></Setter> @@ -123,15 +126,28 @@ <TextBlock DockPanel.Dock="Bottom" Text="{Binding IDSPack.LiquidType.ShortName}" HorizontalAlignment="Center" Margin="0 8 0 0"></TextBlock> <Grid> <Grid ClipToBounds="True" HorizontalAlignment="Center"> - <Path Fill="#4F81BD" > + <Path Fill="{Binding Path=IDSPack.LiquidType, Converter={StaticResource LiquidTypeToBrushConverter}}"> + <Path.Resources> + <sys:Double x:Key="RectWidth">30</sys:Double> + <sys:Double x:Key="RectHeight">88</sys:Double> + </Path.Resources> <Path.Data> <CombinedGeometry GeometryCombineMode="Intersect"> <CombinedGeometry.Geometry1> <StaticResource ResourceKey="InkContainerPath"/> </CombinedGeometry.Geometry1> <CombinedGeometry.Geometry2> - <RectangleGeometry Rect="1,30 30,88" /> - </CombinedGeometry.Geometry2> + <!--Rect="1,30 30,88"--> + <RectangleGeometry > + <RectangleGeometry.Rect> + <MultiBinding Converter="{StaticResource MidTankLevelToElementRectConverter}"> + <Binding Source="{StaticResource RectHeight}"/> + <Binding Source="{StaticResource RectWidth}"/> + <Binding Path="Level" /> + </MultiBinding> + </RectangleGeometry.Rect> + </RectangleGeometry> + </CombinedGeometry.Geometry2> </CombinedGeometry> </Path.Data> </Path> @@ -499,8 +515,9 @@ <Run Text="x"></Run><Run Text="{Binding RunningJobStatus.RemainingUnits}"></Run> </TextBlock>--> </Grid> - <touch:MultiRangeSlider x:Name="PART_LowerSlider" Height="30" Margin="0 0 0 0" Minimum="0" Foreground="{StaticResource TangoDarkForegroundBrush}" - IsSnapToTickEnabled="True" TickFrequency="1" VerticalAlignment="Center" IsEnabled="False" Maximum="{Binding RunningJobStatus.TotalProgressMinusSettingUp}" + <touch:MultiRangeSlider x:Name="PART_LowerSlider" Height="30" Margin="0 0 0 0" Foreground="{StaticResource TangoDarkForegroundBrush}" + IsSnapToTickEnabled="True" TickFrequency="1" VerticalAlignment="Center" Maximum="{Binding RunningJobStatus.TotalProgressMinusSettingUp}" Minimum="0" IsEnabled="False" + MaximumValue ="{Binding RunningJobStatus.TotalProgressMinusSettingUp}" Value ="{Binding RunningJobStatus.ProgressMinusSettingUp}"/> <UniformGrid DockPanel.Dock="Bottom" Columns="4" Rows="1" HorizontalAlignment="Left" Margin="0 35 0 0" Height="Auto" VerticalAlignment="Top" Width="1200"> @@ -746,8 +763,9 @@ <StackPanel Orientation="Vertical" Margin="30 8 30 0" > <locaControls:RunningJobViewerEureka Height="16" DisplayMarkers="False" IsActive="True" Job="{Binding Job}" RunningJobStatus="{Binding RunningJobStatus}" /> - <touch:MultiRangeSlider x:Name="PART_LowerSlider1" Height="26" Margin="0 0 0 0" Minimum="0" Foreground="{StaticResource TangoDarkForegroundBrush}" - IsSnapToTickEnabled="True" TickFrequency="1" VerticalAlignment="Center" IsEnabled="False" Maximum="{Binding RunningJobStatus.TotalProgressMinusSettingUp}" Value ="{Binding RunningJobStatus.ProgressMinusSettingUp}"/> + <touch:MultiRangeSlider x:Name="PART_LowerSlider1" Height="26" Margin="0 0 0 0" Foreground="{StaticResource TangoDarkForegroundBrush}" + IsSnapToTickEnabled="True" TickFrequency="1" VerticalAlignment="Center" Maximum="{Binding RunningJobStatus.TotalProgressMinusSettingUp}" Minimum="0" IsEnabled="False" + MaximumValue ="{Binding RunningJobStatus.TotalProgressMinusSettingUp}" Value ="{Binding RunningJobStatus.ProgressMinusSettingUp}"/> </StackPanel> </DockPanel> |
