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/Tango.PPC.UI/Converters | |
| parent | badb781019975dae252b6f48c757897c4f07b150 (diff) | |
| download | Tango-9f900ab8d1c25e8c62ded7b56cd3991d4cd14248.tar.gz Tango-9f900ab8d1c25e8c62ded7b56cd3991d4cd14248.zip | |
InkLevels converters. Bug in progress bar.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Converters')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/LiquidTypeToBrushConverter.cs | 71 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/Converters/MidTankLevelToElementRectConverter.cs | 36 |
2 files changed, 107 insertions, 0 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(); + } + } +} |
