diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-08-13 19:10:11 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-08-13 19:10:11 +0300 |
| commit | b59b10c6b53f75fd9564662f6c198e794456d47b (patch) | |
| tree | 9766c225ae3c92947af41167972e0c69ff9b9d87 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions | |
| parent | e6a1c01dc220ef50be61b72037e982e20011983e (diff) | |
| parent | 5514eac5e2eb031380b74cf2ec1c697d0d47067e (diff) | |
| download | Tango-b59b10c6b53f75fd9564662f6c198e794456d47b.tar.gz Tango-b59b10c6b53f75fd9564662f6c198e794456d47b.zip | |
Merged RML Extensions feature !!!!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions')
46 files changed, 5845 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/App.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/App.xaml new file mode 100644 index 000000000..6925f5a1b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/App.xaml @@ -0,0 +1,12 @@ +<Application x:Class="Tango.MachineStudio.ThreadExtensions.App" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + <Application.Resources> + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="pack://application:,,,/Tango.MachineStudio.Common;component/Resources/MaterialDesign.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.MachineStudio.Common;component/Themes/LightThemeColors.xaml" /> + </ResourceDictionary.MergedDictionaries> + </ResourceDictionary> + </Application.Resources> +</Application> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Contracts/IMainView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Contracts/IMainView.cs new file mode 100644 index 000000000..cd1bfcd75 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Contracts/IMainView.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.MachineStudio.ThreadExtensions.Contracts +{ + public enum RMLExtensionNavigationView + { + RMLExtentionView, + RMLExtensionsView, + } + + public interface IMainView : IView + { + void NavigateTo(RMLExtensionNavigationView view); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/BoolToDisplayStatusConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/BoolToDisplayStatusConverter.cs new file mode 100644 index 000000000..b06bb0309 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/BoolToDisplayStatusConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace Tango.MachineStudio.ThreadExtensions.Converters +{ + public class BoolToDisplayStatusConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if( value is bool) + { + if((bool)value) + { + return "Done"; + } + } + return "In progress"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ColorNameToBrushConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ColorNameToBrushConverter.cs new file mode 100644 index 000000000..5d97626fe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ColorNameToBrushConverter.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace Tango.MachineStudio.ThreadExtensions.Converters +{ + public class ColorNameToBrushConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + try + { + string colorName = value as string; + if(String.IsNullOrEmpty(colorName)) + { + if(value.GetType().IsEnum ) + { + colorName = value.ToString(); + } + } + if (String.IsNullOrEmpty(colorName)) + { + return new SolidColorBrush(Colors.Transparent); + } + + Color color = (Color)TypeDescriptor.GetConverter(typeof(Color)).ConvertFromString(colorName); + + SolidColorBrush brush = new SolidColorBrush(color); + brush.Opacity = 0.5; + + return brush; + } + catch + { + return new SolidColorBrush(Colors.Transparent); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ColorWithPercentToBrushConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ColorWithPercentToBrushConverter.cs new file mode 100644 index 000000000..eb45b3959 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ColorWithPercentToBrushConverter.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + + +namespace Tango.MachineStudio.ThreadExtensions.Converters +{ + public class ColorWithPercentToBrushConverter : IMultiValueConverter + { + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length == 2) + { + if (values[0].GetType().IsEnum) + { + string colorName = values[0].ToString(); + if (String.IsNullOrEmpty(colorName)) + { + return new SolidColorBrush(Colors.Transparent); + } + int persent = System.Convert.ToInt32(values[1]); + double opacity = persent == 100 ? 0.3 : 0.7; + + Color color = (Color)TypeDescriptor.GetConverter(typeof(Color)).ConvertFromString(colorName); + SolidColorBrush brush = new SolidColorBrush(color); + brush.Opacity = opacity; + return brush; + } + else + { + return new SolidColorBrush(Colors.Transparent); + } + } + else + { + return new SolidColorBrush(Colors.Transparent); + } + } + + //public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + //{ + // throw new NotImplementedException(); + //} + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ComboBoxVisibleConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ComboBoxVisibleConverter.cs new file mode 100644 index 000000000..015290448 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Converters/ComboBoxVisibleConverter.cs @@ -0,0 +1,30 @@ +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.BL.Enumerations; + +namespace Tango.MachineStudio.ThreadExtensions.Converters +{ + public class ComboBoxVisibleConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if(value is RMLExtensionStatus) + { + RMLExtensionStatus enumerationMember = (RMLExtensionStatus)value; + if (enumerationMember == RMLExtensionStatus.New) + return true; + } + return false; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Images/Fabric.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Images/Fabric.jpg Binary files differnew file mode 100644 index 000000000..e9e88434e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Images/Fabric.jpg diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Images/threads.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Images/threads.png Binary files differnew file mode 100644 index 000000000..86eb0b335 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Images/threads.png diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorDataExcelModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorDataExcelModel.cs new file mode 100644 index 000000000..da7471e16 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/ColorDataExcelModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Documents; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class ColorDataExcelModel + { + public int NlCm { get; set; } + public double L { get; set; } + public double A { get; set; } + public double B { get; set; } + + public ColorDataExcelModel() + { + NlCm = 0; + L = A = B = 0.0; + } + + public static void GetDataFromFile(string fileName, out List<ColorDataExcelModel> items, ref string errors) + { + items = null; + try + { + using (ExcelReader reader = new ExcelReader(fileName)) + { + items = reader.GetDataByIndex<ColorDataExcelModel>("Sheet1", 1); + } + } + catch (Exception ex) + { + errors = ex.Message; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/FactorTarget.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/FactorTarget.cs new file mode 100644 index 000000000..0cb2679fd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/FactorTarget.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public static class FactorTarget + { + public static Dictionary<FactorColors, double> FACTOR100 = new Dictionary<FactorColors, double>() { + { FactorColors.CYAN, 51.95}, {FactorColors.MAGENTA, 47.47}, { FactorColors.YELLOW, 94.05}, {FactorColors.BLACK, 26.58}}; + + public static Dictionary<FactorColors, double> FACTOR200 = new Dictionary<FactorColors, double>() { + { FactorColors.CYAN, 46.3}, {FactorColors.MAGENTA, 41.04}, { FactorColors.YELLOW, 97.78}, {FactorColors.BLACK, 21.01}}; + + public static double GetFactor100(FactorColors color) + { + double result; + + if (FACTOR100.TryGetValue(color, out result)) + { + return result; + } + return 0.0; + } + public static double GetFactor200(FactorColors color) + { + double result; + + if (FACTOR200.TryGetValue(color, out result)) + { + return result; + } + return 0.0; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs new file mode 100644 index 000000000..e41a6a220 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/MachineModel.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class MachineModel : ExtendedObject + { + public String Guid { get; set; } + + public string Name { get; set; } + + protected String _serialnumber; + + public String SerialNumber + { + get{ return _serialnumber; } + set + { + _serialnumber = value; + RaisePropertyChangedAuto(); + } + } + + private bool _hasRMLTest; + + public bool HasRMLTest + { + get { return _hasRMLTest; } + set { _hasRMLTest = value; + RaisePropertyChangedAuto(); + } + } + + public MachineModel() + { + HasRMLTest = false; + } + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/PlotProperties.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/PlotProperties.cs new file mode 100644 index 000000000..ee882ad4b --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/PlotProperties.cs @@ -0,0 +1,170 @@ +using OxyPlot; +using OxyPlot.Wpf; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; +using Tango.MachineStudio.ThreadExtensions.ViewModels; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class PlotProperties : ExtendedObject + { + public Plot PlotControl { get; set; } + private IList<DataPoint> _points; + + private FactorColors _color; + + public FactorColors Color + { + get { return _color; } + set { _color = value; } + } + + /// <summary> + /// Binding to ItemsSource of line chart. + /// </summary> + public IList<DataPoint> Points + { + get { return _points; } + set + { + _points = value; + RaisePropertyChangedAuto(); + } + } + private IList<DataPoint> _target100Points; + /// <summary> + /// Binding to ItemsSource of line chart. + /// </summary> + public IList<DataPoint> Target100Points + { + get { return _target100Points; } + set + { + _target100Points = value; + RaisePropertyChangedAuto(); + } + } + private IList<DataPoint> _target200Points; + /// <summary> + /// Binding to ItemsSource of line chart. + /// </summary> + public IList<DataPoint> Target200Points + { + get { return _target200Points; } + set + { + _target200Points = value; + RaisePropertyChangedAuto(); + } + } + private int _step; + public int XStep + { + get { return _step; } + set { _step = value; RaisePropertyChangedAuto(); } + } + + private double _from; + /// <summary> + /// From use to binding to bottom axis min value + /// </summary> + public double From + { + get { return _from; } + set + { + _from = value; RaisePropertyChangedAuto(); + } + } + + private double _to; + /// <summary> + /// To use to binding to bottom axis max value + /// </summary> + public double To + { + get { return _to; } + set + { + _to = value; RaisePropertyChangedAuto(); + } + } + + public PlotProperties(FactorColors color) + { + this.Points = new List<DataPoint>(); + Target100Points = new List<DataPoint>(); + Target200Points = new List<DataPoint>(); + Color = color; + + } + + public void ClearResults() + { + Points.Clear(); + Target100Points.Clear(); + Target200Points.Clear(); + } + + public void CreateGraph(List<ColorProcessData> points, bool isLtype) + { + if (PlotControl == null) + { + Debug.WriteLine("ERROR!!! CreateGraph. Plot Control is NULL."); + return; + } + + ClearResults(); + PlotControl.InvalidatePlot(true); + + double target100Y = FactorTarget.GetFactor100(Color); + double target200Y = FactorTarget.GetFactor200(Color); + + _to = target100Y > target200Y? target100Y + 10: target200Y + 10; + _from = target100Y < target200Y ? target100Y - 10 : target200Y - 10; + + foreach ( var x in points) + { + var point = new DataPoint(x.InkNlCm, isLtype ? x.L : x.B); + Points.Add(point); + + _to = _to > point.Y ? _to : point.Y; + _from = ( _from == 0 || _from > point.Y ) ? point.Y : _from; + + } + if (points.Count > 1) + { + var minInkNlCm = points.Min(n => n.InkNlCm); + var maxInkNlCm = points.Max(n => n.InkNlCm); + if(! Target100Points.Any(x => x.X == minInkNlCm)) + { + Target100Points.Add(new DataPoint(minInkNlCm, target100Y)); + Target200Points.Add(new DataPoint(minInkNlCm, target200Y)); + } + if (!Target100Points.Any(x => x.X == maxInkNlCm)) + { + Target100Points.Add(new DataPoint(maxInkNlCm, target100Y)); + Target200Points.Add(new DataPoint(maxInkNlCm, target200Y)); + } + } + Debug.WriteLine($"CreateGraph. Count Points {points.Count}"); + + if (_to == 0) + _to = isLtype ? 100 : 128; + if (_from == 0) + _from = isLtype ? 0 : -127; + + RaisePropertyChanged("To"); + RaisePropertyChanged("From"); + XStep = (int)(Points.Count / 6); + + PlotControl.InvalidatePlot(true); + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/RmlExtensionModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/RmlExtensionModel.cs new file mode 100644 index 000000000..4b46f2857 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/RmlExtensionModel.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL.Enumerations; +using Tango.Core; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class RmlExtensionModel : ExtendedObject + { + public String Guid { get; set; } + + public String RMLGuid { get; set; } + + public string Name { get; set; } + + public String Manufacturer { get; set; } + + public String Brand { get; set; } + + public int LinearDensity { get; set; } + + public String CreatedBy { get; set;} + + public DateTime Created { get; set; } + + public DateTime LastUpdated { get; set; } + + public RMLExtensionStatus Status{ get; set; } + + public RMLExtensionLevel Level { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9a4711726 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +[assembly: AssemblyTitle("Tango - Machine Studio Thread Extensions Module")] +[assembly: AssemblyVersion("1.0.0.0")] + +[assembly: ComVisible(false)] + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Resources.Designer.cs new file mode 100644 index 000000000..bf79c2402 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.ThreadExtensions.Properties +{ + + + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.ThreadExtensions.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Resources.resx new file mode 100644 index 000000000..af7dbebba --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Settings.Designer.cs new file mode 100644 index 000000000..24bb4eb1e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace Tango.MachineStudio.ThreadExtensions.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Settings.settings new file mode 100644 index 000000000..033d7a5e9 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj new file mode 100644 index 000000000..e700de3d3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -0,0 +1,248 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{859A766B-78AD-484E-9BF2-2CE0FE288894}</ProjectGuid> + <OutputType>library</OutputType> + <RootNamespace>Tango.MachineStudio.ThreadExtensions</RootNamespace> + <AssemblyName>Tango.MachineStudio.ThreadExtensions</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\..\Build\Machine Studio\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\..\Build\Machine Studio\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> + </Reference> + <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath> + </Reference> + <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> + </Reference> + <Reference Include="MahApps.Metro, Version=1.5.0.23, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll</HintPath> + </Reference> + <Reference Include="MaterialDesignColors, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll</HintPath> + </Reference> + <Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="OxyPlot, Version=2.0.0.0, Culture=neutral, PublicKeyToken=638079a8f0bd61e9, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\OxyPlot.Core.2.0.0\lib\net45\OxyPlot.dll</HintPath> + </Reference> + <Reference Include="OxyPlot.Wpf, Version=2.0.0.0, Culture=neutral, PublicKeyToken=75e952ba404cdbb0, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\OxyPlot.Wpf.2.0.0\lib\net45\OxyPlot.Wpf.dll</HintPath> + </Reference> + <Reference Include="ReachFramework" /> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Printing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> + </Reference> + <Reference Include="System.Xml" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xaml"> + <RequiredTargetFramework>4.0</RequiredTargetFramework> + </Reference> + <Reference Include="WindowsBase" /> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\..\..\Versioning\GlobalVersionInfo.cs"> + <Link>GlobalVersionInfo.cs</Link> + </Compile> + <Compile Include="Contracts\IMainView.cs" /> + <Compile Include="Converters\BoolToDisplayStatusConverter.cs" /> + <Compile Include="Converters\ColorNameToBrushConverter.cs" /> + <Compile Include="Converters\ColorWithPercentToBrushConverter.cs" /> + <Compile Include="Converters\ComboBoxVisibleConverter.cs" /> + <Compile Include="Models\ColorDataExcelModel.cs" /> + <Compile Include="Models\FactorTarget.cs" /> + <Compile Include="Models\MachineModel.cs" /> + <Compile Include="Models\PlotProperties.cs" /> + <Compile Include="Models\RmlExtensionModel.cs" /> + <Compile Include="ViewModelLocator.cs" /> + <Compile Include="ViewModels\AddItemDialogVM.cs" /> + <Compile Include="ViewModels\ColorParametersVewVM.cs" /> + <Compile Include="ViewModels\MainViewVM.cs" /> + <Compile Include="ViewModels\TestResultsViewVM.cs" /> + <Compile Include="ViewModels\TestResultViewVM.cs" /> + <Compile Include="Views\AddItemDialog.xaml.cs"> + <DependentUpon>AddItemDialog.xaml</DependentUpon> + </Compile> + <Compile Include="Views\ColorParametersView.xaml.cs"> + <DependentUpon>ColorParametersView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\ComboboxEditable.xaml.cs"> + <DependentUpon>ComboboxEditable.xaml</DependentUpon> + </Compile> + <Compile Include="Views\MachineTestResultsView.xaml.cs"> + <DependentUpon>MachineTestResultsView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\MainView.xaml.cs"> + <DependentUpon>MainView.xaml</DependentUpon> + </Compile> + <Compile Include="ThreadExtensionsModule.cs" /> + <Compile Include="Views\TestResultsView.xaml.cs"> + <DependentUpon>TestResultsView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\ThreadCharacteristicsView.xaml.cs"> + <DependentUpon>ThreadCharacteristicsView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\RMLExtensionView.xaml.cs"> + <DependentUpon>RMLExtensionView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\RMLExtensionsView.xaml.cs"> + <DependentUpon>RMLExtensionsView.xaml</DependentUpon> + </Compile> + <Page Include="App.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\AddItemDialog.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\ColorParametersView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\ComboboxEditable.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\MachineTestResultsView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\MainView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\TestResultsView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\ThreadCharacteristicsView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\RMLExtensionView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> + <Page Include="Views\RMLExtensionsView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <None Include="app.config" /> + <None Include="packages.config" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\threads.png" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj"> + <Project>{bb2abb74-ba58-4812-83aa-ec8171f42df4}</Project> + <Name>Tango.AutoComplete</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Documents\Tango.Documents.csproj"> + <Project>{ca87a608-7b17-4c98-88f2-42abee10f4c1}</Project> + <Name>Tango.Documents</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Settings\Tango.Settings.csproj"> + <Project>{d8f1ad85-526a-4f50-b6dc-d437af63d8d8}</Project> + <Name>Tango.Settings</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.SharedUI\Tango.SharedUI.csproj"> + <Project>{8491D07B-C1F6-4B62-A412-41B9FD2D6538}</Project> + <Name>Tango.SharedUI</Name> + </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.MachineStudio.Common\Tango.MachineStudio.Common.csproj"> + <Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project> + <Name>Tango.MachineStudio.Common</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\Fabric.jpg" /> + </ItemGroup> + <ItemGroup /> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ThreadExtensionsModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ThreadExtensionsModule.cs new file mode 100644 index 000000000..4f949821d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ThreadExtensionsModule.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.BL.Enumerations; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.ThreadExtensions.Views; +using Tango.SharedUI.Helpers; + +namespace Tango.MachineStudio.ThreadExtensions +{ + [StudioModule(25)] + public class ThreadExtensionsModule : StudioModuleBase + { + public override string Name + { + get + { + return "RML Extensions"; + } + } + + public override string Description + { + get + { + return "RML extensions and data collection."; + } + } + + public override BitmapSource Image + { + get + { + return ResourceHelper.GetImageFromResources("Images/Fabric.jpg"); + } + } + + public override Type MainViewType + { + get + { + return typeof(MainView); + } + } + + public override Permissions Permission + { + get + { + return Permissions.RunMachineStudio; + } + } + + public override void Dispose() + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModelLocator.cs new file mode 100644 index 000000000..596332f8d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModelLocator.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; +using Tango.MachineStudio.ThreadExtensions.ViewModels; + +namespace Tango.MachineStudio.ThreadExtensions +{ + public static class ViewModelLocator + { + /// <summary> + /// Initializes a new instance of the ViewModelLocator class. + /// </summary> + static ViewModelLocator() + { + TangoIOC.Default.Register<MainViewVM>(); + TangoIOC.Default.Register<AddItemDialogVM>(); + } + + public static MainViewVM MainViewVM + { + get + { + return TangoIOC.Default.GetInstance<MainViewVM>(); + } + } + + public static AddItemDialogVM AddItemDialogVM + { + get + { + return TangoIOC.Default.GetInstance<AddItemDialogVM>(); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/AddItemDialogVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/AddItemDialogVM.cs new file mode 100644 index 000000000..0187f3bee --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/AddItemDialogVM.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.SharedUI; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class AddItemDialogVM : DialogViewVM + { + private string _name; + + public string Name + { + get { return _name; } + set { _name = value; + RaisePropertyChangedAuto(); + SaveCommand.RaiseCanExecuteChanged(); + } + } + + + /// <summary> + /// Gets or sets the login command. + /// </summary> + public RelayCommand SaveCommand { get; set; } + + /// <summary> + /// Gets or sets the cancel command. + /// </summary> + public RelayCommand CancelCommand { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="MachineLoginViewVM"/> class. + /// </summary> + public AddItemDialogVM() + { + SaveCommand = new RelayCommand(Accept, () => false == String.IsNullOrEmpty(Name)); + CancelCommand = new RelayCommand(Cancel); + } + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs new file mode 100644 index 000000000..a89a2e33c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/ColorParametersVewVM.cs @@ -0,0 +1,817 @@ +using OxyPlot; +using OxyPlot.Wpf; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.ActionLogs; +using Tango.BL.Builders; +using Tango.BL.DTO; +using Tango.BL.Entities; +using Tango.Core; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; +using Tango.AutoComplete.Editors; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.Core.Commands; +using Microsoft.Win32; +using System.Diagnostics; +using Tango.Settings; +using Tango.MachineStudio.Common; +using Tango.Logging; +using Tango.BL.Enumerations; +using System.Data.Entity; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class ColorParametersVewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + private ObservablesContext _active_context; + + public event EventHandler SaveColorParameters; + + #region Properties + + private ColorProcessParameter _selectedColorProcessparameter; + /// <summary> + /// Gets or sets the selected RML. + /// </summary> + public ColorProcessParameter SelectedColorProcessParameter + { + get { return _selectedColorProcessparameter; } + set + { + _selectedColorProcessparameter = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessData> _magentaProcessData; + public ObservableCollection<ColorProcessData> MagentaProcessData + { + get + { + return _magentaProcessData; + } + set + { + _magentaProcessData = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessData> _cyanProcessData; + public ObservableCollection<ColorProcessData> CyanProcessData + { + get + { + return _cyanProcessData; + } + set + { + _cyanProcessData = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessData> _yellowProcessData; + public ObservableCollection<ColorProcessData> YellowProcessData + { + get + { + return _yellowProcessData; + } + set + { + _yellowProcessData = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessData> _blackProcessData; + public ObservableCollection<ColorProcessData> BlackProcessData + { + get + { + return _blackProcessData; + } + set + { + _blackProcessData = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessFactor> _factor100ProcessData; + public ObservableCollection<ColorProcessFactor> Factor100ProcessData + { + get + { + return _factor100ProcessData; + } + set + { + _factor100ProcessData = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessFactor> _factor200ProcessData; + public ObservableCollection<ColorProcessFactor> Factor200ProcessData + { + get + { + return _factor200ProcessData; + } + set + { + _factor200ProcessData = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessFactor> _minInkUptake; + public ObservableCollection<ColorProcessFactor> MinInkUptake + { + get + { + return _minInkUptake; + } + set + { + _minInkUptake = value; + RaisePropertyChangedAuto(); + } + } + + private ObservableCollection<ColorProcessFactor> _maxInkUptake; + public ObservableCollection<ColorProcessFactor> MaxInkUptake + { + get + { + return _maxInkUptake; + } + set + { + _maxInkUptake = value; + RaisePropertyChangedAuto(); + } + } + + + private PlotProperties _cyanPlot; + + public PlotProperties CyanPlot + { + get { return _cyanPlot; } + set + { + _cyanPlot = value; + RaisePropertyChangedAuto(); + } + } + + private PlotProperties _magentaPlot; + + public PlotProperties MagentaPlot + { + get { return _magentaPlot; } + set { _magentaPlot = value; } + } + + private PlotProperties _yellowPlot; + + public PlotProperties YellowPlot + { + get { return _yellowPlot; } + set { _yellowPlot = value; } + } + + private PlotProperties _blackPlot; + + public PlotProperties BlackPlot + { + get { return _blackPlot; } + set { _blackPlot = value; } + } + + private string _RMLExtentionGUID; + + public string RMLExtemtionGUID + { + get { return _RMLExtentionGUID; } + set + { + _RMLExtentionGUID = value; + OnRMLExtensionGUIDChanged(); + } + } + + private string _RMLGUID; + + public string RMLGUID + { + get { return _RMLGUID; } + set + { + _RMLGUID = value; + OnRMLExtensionGUIDChanged(); + } + } + + protected string _selectedMachineGuid; + /// <summary> + /// Gets or sets the selected machine. + /// </summary> + public String SelectedMachineGUID + { + get { return _selectedMachineGuid; } + set + { + if (value != null && _selectedMachineGuid != value) + { + _selectedMachineGuid = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + } + + private bool _isViewLoaded; + /// <summary> + /// Gets or sets a value indicating whether this instance is view loaded. Used to update charts. + /// </summary> + /// <value> + /// <c>true</c> if this instance is view loaded; otherwise, <c>false</c>. + /// </value> + public bool IsViewLoaded + { + get { return _isViewLoaded; } + set + { + if (_isViewLoaded != value) + { + _isViewLoaded = value; + } + } + } + + /// <summary> + /// Saved guid of the removed color process data before save. + /// </summary> + private List<string> RemovedColorProcessDataBeforeSave { get; set;} + + #endregion + #region commands + + public RelayCommand SaveCommand { get; set; } + + public RelayCommand SaveFactorsCommand { get; set; } + + public RelayCommand ImportCyanDataCommand { get; set; } + public RelayCommand ImportMagentaDataCommand { get; set; } + public RelayCommand ImportYellowDataCommand { get; set; } + public RelayCommand ImportBlackDataCommand { get; set; } + + private void ImportMagentaData(object obj) + { + List<ColorDataExcelModel> items; + if (LoadColorDataFromExcel(out items) && items != null) + { + MagentaProcessData.Clear(); + RemoveColorDataByColor((int)FactorColors.MAGENTA, SelectedColorProcessParameter.Guid); + items.ForEach(x => MagentaProcessData.Add(new ColorProcessData() { InkNlCm = x.NlCm, L = x.L, A = x.A, B = x.B, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid })); + MagentaPlot.CreateGraph(MagentaProcessData.ToList(), true); + UpdateFactorsOnChangeProcessData(FactorColors.MAGENTA); + } + } + + private void ImportYellowData(object obj) + { + List<ColorDataExcelModel> items; + if (LoadColorDataFromExcel(out items) && items != null) + { + YellowProcessData.Clear(); + RemoveColorDataByColor((int)FactorColors.YELLOW, SelectedColorProcessParameter.Guid); + items.ForEach(x => YellowProcessData.Add(new ColorProcessData() { InkNlCm = x.NlCm, L = x.L, A = x.A, B = x.B, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid })); + YellowPlot.CreateGraph(YellowProcessData.ToList(), false); + UpdateFactorsOnChangeProcessData(FactorColors.YELLOW); + } + } + + private void ImportCyanData(object obj) + { + List<ColorDataExcelModel> items; + if (LoadColorDataFromExcel(out items) && items != null) + { + CyanProcessData.Clear(); + RemoveColorDataByColor((int)FactorColors.CYAN, SelectedColorProcessParameter.Guid); + items.ForEach(x => CyanProcessData.Add(new ColorProcessData() { InkNlCm = x.NlCm, L = x.L, A = x.A, B = x.B, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid })); + CyanPlot.CreateGraph(CyanProcessData.ToList(), true); + UpdateFactorsOnChangeProcessData(FactorColors.CYAN); + } + } + + + private void ImportBlackData(object obj) + { + List<ColorDataExcelModel> items; + if (LoadColorDataFromExcel(out items) && items != null) + { + BlackProcessData.Clear(); + RemoveColorDataByColor((int)FactorColors.BLACK, SelectedColorProcessParameter.Guid); + items.ForEach(x => BlackProcessData.Add(new ColorProcessData() { InkNlCm = x.NlCm, L = x.L, A = x.A, B = x.B, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid })); + BlackPlot.CreateGraph(BlackProcessData.ToList(), true); + UpdateFactorsOnChangeProcessData(FactorColors.BLACK); + } + } + + private async void SaveFactors(object obj) + { + using (var context = ObservablesContext.CreateDefault()) + { + try { + var rml = await new RmlBuilder(context) + .Set(RMLGUID) + .WithLiquidFactors() + .BuildAsync(); + var LiquidTypesRml = rml.LiquidTypesRmls; + foreach (var factor in Factor100ProcessData) + { + var liquidFactor = LiquidTypesRml.ToList().First(x => x.LiquidType.Name.ToLower() == factor.FactorColor.ToDescription().ToLower()); + if(liquidFactor != null) + { + liquidFactor.MaxNlPerCm = factor.InkNlCm; + } + } + await context.SaveChangesAsync(); + } + catch(Exception ex) + { + LogManager.Log(ex, "Could not update color factor."); + _notification.ShowError($"An error occurred while trying to save color factors.\n{ex.Message}"); + } + } + + } + + + private bool LoadColorDataFromExcel(out List<ColorDataExcelModel> items) + { + OpenFileDialog dlg = new OpenFileDialog(); + items = null; + try + { + dlg.Title = $"Import excel file with data"; + dlg.Filter = "Excel Files|*.xlsx"; + if (dlg.ShowDialog().Value) + { + string error = ""; + ColorDataExcelModel.GetDataFromFile(dlg.FileName, out items, ref error); + if (false == String.IsNullOrEmpty(error) || items == null || items.Count == 0) + { + _notification.ShowError("An error occurred while trying to import data form the selected excel file. Please check the file format if valid and is available to read."); + return false; + } + return true; + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error importing excel file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to import the selected excel file. Please check the file format if valid and is available to read."); + } + return false; + } + + #endregion + + public ColorParametersVewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + _isViewLoaded = false; + RemovedColorProcessDataBeforeSave = new List<string>(); + + + CyanProcessData = new ObservableCollection<ColorProcessData>(); + CyanProcessData.CollectionChanged += OnCyanCollectionChanged; + + MagentaProcessData = new ObservableCollection<ColorProcessData>(); + MagentaProcessData.CollectionChanged += OnMagentaCollectionChanged; + + YellowProcessData = new ObservableCollection<ColorProcessData>(); + YellowProcessData.CollectionChanged += OnYellowCollectionChanged; + + BlackProcessData = new ObservableCollection<ColorProcessData>(); + BlackProcessData.CollectionChanged += OnBlackCollectionChanged; + + CyanPlot = new PlotProperties(FactorColors.CYAN); + YellowPlot = new PlotProperties(FactorColors.YELLOW); + MagentaPlot = new PlotProperties(FactorColors.MAGENTA); + BlackPlot = new PlotProperties(FactorColors.BLACK); + + SaveCommand = new RelayCommand(Save, () => IsFree); + ImportCyanDataCommand = new RelayCommand(ImportCyanData); + ImportMagentaDataCommand = new RelayCommand(ImportMagentaData); + ImportYellowDataCommand = new RelayCommand(ImportYellowData); + ImportBlackDataCommand = new RelayCommand(ImportBlackData); + + SaveFactorsCommand = new RelayCommand(SaveFactors, () => IsFree); + } + + + #region Loading + + public async void LoadColorParameters() + { + if (SelectedMachineGUID == null) + { + _notification.ShowWarning(LogManager.Log($"Please, select machine.", LogCategory.Warning)); + IsFree = false; + return; + } + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + + await Task.Factory.StartNew(() => + { + using (_notification.PushTaskItem("Loading Color Process Parameters ...")) + { + + var currentcolorProcessParameter = _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == RMLExtemtionGUID && x.MachineGuid == SelectedMachineGUID).FirstOrDefault(); + if (currentcolorProcessParameter != null) + { + SelectedColorProcessParameter = new ColorProcessParametersBuilder(_active_context).Set(currentcolorProcessParameter.Guid).WithColorProcessData().WithColorProcessFactor().Build(); + } + + if (SelectedColorProcessParameter == null) + { + SelectedColorProcessParameter = new ColorProcessParameter() { RmlsExtensionsGuid = RMLExtemtionGUID, MachineGuid = SelectedMachineGUID }; + SelectedColorProcessParameter.WhitePointL = 0.0; + SelectedColorProcessParameter.WhitePointA = 0.0; + SelectedColorProcessParameter.WhitePointB = 0.0; + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.CYAN, FactorPercent = 100, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.MAGENTA, FactorPercent = 100, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.YELLOW, FactorPercent = 100, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.BLACK, FactorPercent = 100, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.CYAN, FactorPercent = 200, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.MAGENTA, FactorPercent = 200, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.YELLOW, FactorPercent = 200, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.BLACK, FactorPercent = 200, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.CYAN, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.MAGENTA, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.YELLOW, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.BLACK, FactorPercent = 1, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.CYAN, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.MAGENTA, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.YELLOW, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + SelectedColorProcessParameter.ColorProcessFactors.Add(new ColorProcessFactor() { FactorColor = FactorColors.BLACK, FactorPercent = 1111, ColorProcessParametersGuid = SelectedColorProcessParameter.Guid }); + _active_context.ColorProcessParameters.Add(SelectedColorProcessParameter); + _active_context.SaveChangesAsync(); + } + + } + }); + + LoadParameters(); + IsFree = true; + } + + private void LoadParameters() + { + Factor100ProcessData = SelectedColorProcessParameter.ColorProcessFactors.Where(x => x.FactorPercent == 100).ToObservableCollection(); + + Factor200ProcessData = SelectedColorProcessParameter.ColorProcessFactors.Where(x => x.FactorPercent == 200).ToObservableCollection(); + + MinInkUptake = SelectedColorProcessParameter.ColorProcessFactors.Where(x => x.FactorPercent == 1).ToObservableCollection(); + + MaxInkUptake = SelectedColorProcessParameter.ColorProcessFactors.Where(x => x.FactorPercent == 1111).ToObservableCollection(); + + RemovedColorProcessDataBeforeSave.Clear(); + + var cyanDataList = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == FactorColors.CYAN).ToList().OrderBy(x => x.InkNlCm).ToList(); + CyanProcessData.Clear(); + cyanDataList.ForEach(y => CyanProcessData.Add(y)); + + var magentaDatalist = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == FactorColors.MAGENTA).ToList().OrderBy(x => x.InkNlCm).ToList(); ; + MagentaProcessData.Clear(); + magentaDatalist.ForEach(y => MagentaProcessData.Add(y)); + + var yellowDatalist = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == FactorColors.YELLOW).ToList().OrderBy(x => x.InkNlCm).ToList(); ; + YellowProcessData.Clear(); + yellowDatalist.ForEach(y => YellowProcessData.Add(y)); + + var blackDatalist = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == FactorColors.BLACK).ToList().OrderBy(x => x.InkNlCm).ToList(); ; + BlackProcessData.Clear(); + blackDatalist.ForEach(y => BlackProcessData.Add(y)); + + UpdatePlots(); + SelectedColorProcessParameter.ColorProcessFactors.ToList().ForEach(x => UpdateFactorsOnChangeProcessData(x.FactorColor)); + } + + private void OnRMLExtensionGUIDChanged() + { + SelectedColorProcessParameter = null; + } + + private void SelectedMachineChanged() + { + SelectedColorProcessParameter = null; + LoadColorParameters(); + } + #endregion + + #region Update Plot + + public void UpdatePlots() + { + if (IsViewLoaded) + { + CyanPlot.CreateGraph(CyanProcessData.ToList(), true); + MagentaPlot.CreateGraph(MagentaProcessData.ToList(), true); + YellowPlot.CreateGraph(YellowProcessData.ToList(), false); + BlackPlot.CreateGraph(BlackProcessData.ToList(), true); + } + } + + private void OnCyanCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + OnColorCollectionChange(e, FactorColors.CYAN, CyanMeasurementModelPropertyChanged); + } + + private void CyanMeasurementModelPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (IsFree) + { + CyanPlot.CreateGraph(CyanProcessData.ToList(), true); + UpdateFactorsOnChangeProcessData(FactorColors.CYAN); + } + } + + private void OnMagentaCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + OnColorCollectionChange(e, FactorColors.MAGENTA, MagentaMeasurementModelPropertyChanged); + } + + private void MagentaMeasurementModelPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (IsFree) + { + MagentaPlot.CreateGraph(MagentaProcessData.ToList(), true); + UpdateFactorsOnChangeProcessData(FactorColors.MAGENTA); + } + } + + private void OnYellowCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + OnColorCollectionChange(e, FactorColors.YELLOW, YellowMeasurementModelPropertyChanged); + } + + private void YellowMeasurementModelPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (IsFree) + { + YellowPlot.CreateGraph(YellowProcessData.ToList(), false); + UpdateFactorsOnChangeProcessData(FactorColors.YELLOW); + } + } + + private void OnBlackCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + OnColorCollectionChange(e, FactorColors.BLACK, BlackMeasurementModelPropertyChanged); + } + + private void BlackMeasurementModelPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (IsFree) + { + BlackPlot.CreateGraph(BlackProcessData.ToList(), true); + UpdateFactorsOnChangeProcessData(FactorColors.BLACK); + } + } + + private void OnColorCollectionChange(NotifyCollectionChangedEventArgs e, FactorColors color, PropertyChangedEventHandler eventHandler) + { + if (e.Action == NotifyCollectionChangedAction.Reset) + { + var processData = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == color).ToObservableCollection(); + + foreach (ColorProcessData item in processData) + { + item.PropertyChanged -= eventHandler; + SelectedColorProcessParameter.ColorProcessData.Remove(item); + } + //UpdateFactorsOnChangeProcessData(color); + } + else if (e.Action == NotifyCollectionChangedAction.Remove) + { + foreach (ColorProcessData item in e.OldItems) + { + SelectedColorProcessParameter.ColorProcessData.Remove(item); + item.PropertyChanged -= eventHandler; + RemovedColorProcessDataBeforeSave.Add(item.Guid); + } + UpdateFactorsOnChangeProcessData(color); + } + else if (e.Action == NotifyCollectionChangedAction.Add) + { + foreach (ColorProcessData item in e.NewItems) + { + item.FactorColor = color; + item.ColorProcessParametersGuid = SelectedColorProcessParameter.Guid; + SelectedColorProcessParameter.ColorProcessData.Add(item); + item.PropertyChanged += eventHandler; + } + } + } + #endregion + + #region update factors + + /// <summary> + /// Updates the ColorProcessFactor from ColorProcessData item. + /// </summary> + /// <param name="factor">The factor.</param> + /// <param name="item">The item.</param> + private void UpdateFactor(ColorProcessFactor factor, DataPoint point) + { + if (factor == null) + return; + if (point.X == 0) + { + factor.InkNlCm = 0; + factor.L = factor.A = factor.B = 0.0; + return; + } + factor.InkNlCm = (int)point.X; + + } + + /// <summary> + /// Calculate and Update the factors on change process data. + /// </summary> + /// <param name="color">The color.</param> + private void UpdateFactorsOnChangeProcessData(FactorColors color) + { + bool isLtype = color == FactorColors.YELLOW ? false : true; + var processData = SelectedColorProcessParameter.ColorProcessData.Where(x => x.FactorColor == color).ToList(); + double target100 = FactorTarget.GetFactor100(color); + double target200 = FactorTarget.GetFactor200(color); + //ColorProcessData closest100 = null; + //ColorProcessData closest200 = null; + + //var minDifference100 = double.MaxValue; + //var minDifference200 = double.MaxValue; + + if (processData.Count == 0) + return; + + //foreach (var item in processData) + //{ + // var colorvalue = isLtype ? item.L : item.B; + // var difference100 = Math.Abs(colorvalue - target100); + // if (minDifference100 > difference100) + // { + // minDifference100 = (int)difference100; + // closest100 = item; + // } + // var difference200 = Math.Abs(colorvalue - target200); + // if (minDifference200 > difference200) + // { + // minDifference200 = (int)difference200; + // closest200 = item; + // } + //} + var point100 = GetTargetPoint(processData, target100, isLtype); + UpdateFactor(Factor100ProcessData.FirstOrDefault(x => x.FactorColor == color), point100); + var point200 = GetTargetPoint(processData, target200, isLtype); + UpdateFactor(Factor200ProcessData.FirstOrDefault(x => x.FactorColor == color), point200); + } + + private DataPoint GetTargetPoint(List<ColorProcessData> listValues, double factor, bool isLtype) + { + if (listValues.Count < 2 || factor <= 0) + return new DataPoint(0, 0); + + var test = listValues.GroupBy(x => x.InkNlCm, x => isLtype ? x.L : x.B, (Ink, Value) => new { InkValuep = Ink, ColorValue = Value.Average() }).ToList(); + var distinctItems = listValues.GroupBy(x => x.InkNlCm, x => isLtype ? x.L : x.B, (Ink, Value) => new { InkValuep = Ink, ColorValue = Value }).Select(y => new ColorProcessData { InkNlCm = y.InkValuep, L = y.ColorValue.Average() }).ToList(); + + double calculatedX = 0.0; + ColorProcessData prevItem = distinctItems[0]; + for (int index = 1; index < distinctItems.Count; index++) + { + var item = distinctItems[index]; + if (prevItem.L > item.L && (factor > prevItem.L || (factor <= prevItem.L && factor >= item.L)) + || (prevItem.L <= item.L && (factor > prevItem.L || (factor >= prevItem.L && factor <= item.L))) + || ((index + 1) == distinctItems.Count && calculatedX == 0.0)) + { + calculatedX = CalculateXValue(factor, new DataPoint(prevItem.InkNlCm, prevItem.L), new DataPoint(item.InkNlCm, item.L)); + break; + + } + prevItem = item; + } + + return new DataPoint(calculatedX, factor); ; + } + + private double CalculateXValue(double factor, DataPoint leftPoint, DataPoint rightPoint) + { + double deltaX = rightPoint.X - leftPoint.X; + double deltaY = rightPoint.Y - leftPoint.Y; + + // prevents division by zero exceptions. + if (deltaX == 0) + return 0.0; + + double slope = deltaY / deltaX; + + // double c = leftPoint.Y - slope * leftPoint.X; + // double cX = (factor - c) / slope; + + return (leftPoint.X + (factor - leftPoint.Y) / slope); + + } + #endregion + + #region save + + private async void RemoveColorDataByColor(int color, string colorProcessParamGuid) + { + if(_active_context == null) + { + return; + } + var existingColorProcessData = await _active_context.ColorProcessData.Where(y => y.Color == color && y.ColorProcessParametersGuid == colorProcessParamGuid).ToListAsync(); + foreach( var data in existingColorProcessData) + { + _active_context.ColorProcessData.Remove(data); + } + } + public async void Save() + { + if (String.IsNullOrEmpty(SelectedMachineGUID)) + { + _notification.ShowWarning(LogManager.Log($"Could not save Color Process Parameters. Please, select machine before save.", LogCategory.Warning)); + return; + } + + try + { + IsFree = false; + + SelectedColorProcessParameter.LastUpdated = DateTime.UtcNow; + + foreach (var item in RemovedColorProcessDataBeforeSave) + { + var existingColorProcessData = await _active_context.ColorProcessData.FirstOrDefaultAsync(y => y.Guid == item); + if (existingColorProcessData != null) + { + _active_context.ColorProcessData.Remove(existingColorProcessData); + } + } + foreach(var colordata in SelectedColorProcessParameter.ColorProcessData) + { + colordata.LastUpdated = DateTime.UtcNow; + } + foreach (var factordata in SelectedColorProcessParameter.ColorProcessFactors) + { + factordata.LastUpdated = DateTime.UtcNow; + } + + await _active_context.SaveChangesAsync(); + + LoadColorParameters(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not update color parameters."); + _notification.ShowError($"An error occurred while trying to save color parameters.\n{ex.Message}"); + } + finally + { + IsFree = true; + EventHandler handler = SaveColorParameters; + handler?.Invoke(this, new EventArgs()); + } + } + + #endregion + } +} + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs new file mode 100644 index 000000000..0665c146a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -0,0 +1,1132 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.Calibration; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Notifications; + + +using System.Data.Entity; +using Tango.Core.ExtensionMethods; +using Tango.MachineStudio.Common.Authentication; +using Tango.BL.ActionLogs; +using Tango.BL.DTO; +using Tango.BL.Enumerations; +using Tango.MachineStudio.ThreadExtensions.Contracts; +using Tango.MachineStudio.ThreadExtensions.Views; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.Settings; +using System.Reflection; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class MainViewVM : StudioViewModel<IMainView> + { + private INotificationProvider _notification; + private IAuthenticationProvider _authentication; + private IActionLogManager _actionLogManager; + + private ObservablesContext _rmlExtentions_context; + private ObservablesContext _active_context; + + private List<User> _allUsers; + + #region properties + //private ObservableCollection<RmlsExtension> _rmlsExtension; + //public ObservableCollection<RmlsExtension> RmlsExtensions + //{ + // get { return _rmlsExtension; } + // set { _rmlsExtension = value; + // RaisePropertyChangedAuto(); } + //} + + private List<RmlExtensionModel> _rmlExtensions; + public List<RmlExtensionModel> RmlExtensions + { + get { return _rmlExtensions; } + set { _rmlExtensions = value; + RaisePropertyChangedAuto(); } + } + + private RmlsExtension _ActiveRMLExtension; + public RmlsExtension ActiveRMLExtension + { + get { return _ActiveRMLExtension; } + set { _ActiveRMLExtension = value; + RaisePropertyChangedAuto(); } + } + + private Rml _activeRML; + public Rml ActiveRML + { + get { return _activeRML; } + set + { + _activeRML = value; + RaisePropertyChangedAuto(); + } + } + + private RmlExtensionModel _selectedRMLExtension; + public RmlExtensionModel SelectedRMLExtension + { + get { return _selectedRMLExtension; } + set { _selectedRMLExtension = value; + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); } + } + + //private ICollectionView _rmlExtCollectionView; + ///// <summary> + ///// Gets or sets the RML collection view. + ///// </summary> + //public ICollectionView RmlExtCollectionView + //{ + // get { return _rmlExtCollectionView; } + // set + // { + // _rmlExtCollectionView = value; + // RaisePropertyChangedAuto(); + // } + //} + + private ObservableCollection<YarnApplication> _applications; + public ObservableCollection<YarnApplication> Applications + { + get { return _applications; } + set { _applications = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnBrand> _brands; + public ObservableCollection<YarnBrand> Brands + { + get { return _brands; } + set { _brands = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnWhiteShade> _yarnWhiteShade; + public ObservableCollection<YarnWhiteShade> YarnWhiteShade + { + get { return _yarnWhiteShade; } + set { _yarnWhiteShade = value; RaisePropertyChangedAuto(); } + } + private ObservableCollection<MediaPurpos> _enduse; + public ObservableCollection<MediaPurpos> EndUse + { + get { return _enduse; } + set { _enduse = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<LinearMassDensityUnit> _units; + public ObservableCollection<LinearMassDensityUnit> Units + { + get { return _units; } + set { _units = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnFamily> _family; + public ObservableCollection<YarnFamily> Family + { + get { return _family; } + set { _family = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<FiberShape> _geometry; + public ObservableCollection<FiberShape> Geometry + { + get { return _geometry; } + set { _geometry = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnGlossLevel> _glosslevel; + public ObservableCollection<YarnGlossLevel> GlossLevel + { + get { return _glosslevel; } + set { _glosslevel = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnGroup> _group; + public ObservableCollection<YarnGroup> Group + { + get { return _group; } + set { _group = value; RaisePropertyChangedAuto(); } + } + + private List<String> _manufacturers; + + public List<String> Manufacturers + { + get { return _manufacturers; } + set { _manufacturers = value; + RaisePropertyChangedAuto(); + } + } + + + private ObservableCollection<MediaMaterial> _materials; + public ObservableCollection<MediaMaterial> Materials + { + get { return _materials; } + set { _materials = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnSubFamily> _subFamilies; + public ObservableCollection<YarnSubFamily> SubFamilies + { + get { return _subFamilies; } + set { _subFamilies = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnTexturing> _texturing; + public ObservableCollection<YarnTexturing> Texturing + { + get { return _texturing; } + set { _texturing = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnType> _yarnTypes; + public ObservableCollection<YarnType> YarnTypes + { + get { return _yarnTypes; } + set { _yarnTypes = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection<YarnIndustrysector> _industrySector; + public ObservableCollection<YarnIndustrysector> IndustrySector + { + get { return _industrySector; } + set { _industrySector = value; RaisePropertyChangedAuto(); } + } + + private String _Filter; + /// <summary> + /// Gets or sets the search filter. + /// </summary> + public String Filter + { + get { return _Filter; } + set { _Filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + } + + private async void OnFilterChanged() + { + await LoadRmlExtentions(); + } + + private ColorParametersVewVM _colorParametersVewVM; + public ColorParametersVewVM ColorParametersVewVM + { + get { return _colorParametersVewVM; } + set { _colorParametersVewVM = value; RaisePropertyChangedAuto(); } + } + + private TestResultsViewVM _testResultsViewVM; + public TestResultsViewVM TestResultsViewVM + { + get { return _testResultsViewVM; } + set { _testResultsViewVM = value; RaisePropertyChangedAuto(); } + } + + protected MachineModel _selectedMachine; + /// <summary> + /// Gets or sets the selected machine. + /// </summary> + public MachineModel SelectedMachine + { + get { return _selectedMachine; } + set + { + if (value != null && _selectedMachine != value) + { + _selectedMachine = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + } + + private ObservableCollection<MachineModel> _machines; + /// <summary> + /// Gets or sets the Machines. + /// </summary> + public ObservableCollection<MachineModel> Machines + { + get + { + return _machines; + } + + set + { + _machines = value; RaisePropertyChanged(nameof(Machines)); + } + + } + + #endregion + + #region commands + + public RelayCommand SaveCommand { get; set; } + + public RelayCommand ManageRmlExtensionCommand { get; set; } + + public RelayCommand BackToThreadExtensionViewsCommand { get; set; } + + private async void BackToThreadExtensionViews(object obj) + { + View.NavigateTo(RMLExtensionNavigationView.RMLExtensionsView); + await LoadRmlExtentions(); + } + + public RelayCommand AddManufacturerItemCommand { get; set;} + public RelayCommand EditManufacturerItemCommand { get; set; } + public RelayCommand DeleteManufacturerItemCommand { get; set; } + + public RelayCommand AddBrandItemCommand { get; set; } + public RelayCommand EditBrandItemCommand { get; set; } + public RelayCommand DeleteBrandItemCommand { get; set; } + + public RelayCommand AddEndUseItemCommand { get; set; } + public RelayCommand EditEndUseItemCommand { get; set; } + public RelayCommand DeleteEndUseItemCommand { get; set; } + + public RelayCommand AddApplicationItemCommand { get; set; } + public RelayCommand EditApplicationItemCommand { get; set; } + public RelayCommand DeleteApplicationItemCommand { get; set; } + + public RelayCommand AddIndustrySectorItemCommand { get; set; } + public RelayCommand EditIndustrySectorItemCommand { get; set; } + public RelayCommand DeleteIndustrySectorItemCommand { get; set; } + + public RelayCommand AddMaterialItemCommand { get; set; } + public RelayCommand EditMaterialItemCommand { get; set; } + public RelayCommand DeleteMaterialItemCommand { get; set; } + + public RelayCommand AddYarnTypeItemCommand { get; set; } + public RelayCommand EditYarnTypeItemCommand { get; set; } + public RelayCommand DeleteYarnTypeItemCommand { get; set; } + + public RelayCommand AddSubFamilyItemCommand { get; set; } + public RelayCommand EditSubFamilyItemCommand { get; set; } + public RelayCommand DeleteSubFamilyItemCommand { get; set; } + + public RelayCommand AddFamilyItemCommand { get; set; } + public RelayCommand EditFamilyItemCommand { get; set; } + public RelayCommand DeleteFamilyItemCommand { get; set; } + + public RelayCommand AddGroupItemCommand { get; set; } + public RelayCommand EditGroupItemCommand { get; set; } + public RelayCommand DeleteGroupItemCommand { get; set; } + + public RelayCommand AddTexturingItemCommand { get; set; } + public RelayCommand EditTexturingItemCommand { get; set; } + public RelayCommand DeleteTexturingItemCommand { get; set; } + + public RelayCommand AddGeometryItemCommand { get; set; } + public RelayCommand EditGeometryItemCommand { get; set; } + public RelayCommand DeleteGeometryItemCommand { get; set; } + + public RelayCommand AddYarnWhiteShadeItemCommand { get; set; } + public RelayCommand EditYarnWhiteShadeItemCommand { get; set; } + public RelayCommand DeleteYarnWhiteShadeItemCommand { get; set; } + + public RelayCommand AddGlossLevelItemCommand { get; set; } + public RelayCommand EditGlossLevelItemCommand { get; set; } + public RelayCommand DeleteGlossLevelItemCommand { get; set; } + + #endregion + + #region Command Functions + + private async void AddManufacturerItem(object obj) + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + vm.Name = ""; + + _notification.ShowModalDialog<AddItemDialogVM, Views.AddItemDialog>(vm, (x) => + { + if (Manufacturers.Any(y => y.ToLower() == vm.Name.ToLower())) + { + _notification.ShowError("Manufacturer already exists."); + return; + } + _active_context.YarnManufacturers.Add(new YarnManufacturer() { Name = vm.Name }); + + }, () => { }); + if(vm.DialogResult) + { + await _active_context.SaveChangesAsync(); + Manufacturers = _active_context.YarnManufacturers.Select(z => z.Name).ToList(); + ActiveRML.Manufacturer = Manufacturers.Where(z=> z == vm.Name).FirstOrDefault(); + } + } + + private async void EditManufacturerItem(object obj) + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + vm.Name = ActiveRML.Manufacturer; + bool bChanged = false; + + _notification.ShowModalDialog<AddItemDialogVM, Views.AddItemDialog>(vm, (x) => + { + if (ActiveRML.Manufacturer == x.Name) + return; + if (Manufacturers.Any(y => y == x.Name)) + { + _notification.ShowError("Manufacturer already exists."); + return; + } + var editItem = _active_context.YarnManufacturers.Where(z => z.Name == ActiveRML.Manufacturer).FirstOrDefault(); + if (editItem != null) + { + editItem.Name = x.Name; + ActiveRML.Manufacturer = x.Name; + bChanged = true; + } + }, () => { }); + if(bChanged) + { + await _active_context.SaveChangesAsync(); + Manufacturers = _active_context.YarnManufacturers.Select(x => x.Name).ToList(); + } + + } + + private bool AddItemToCollection<T>( ObservableCollection<T> collection, DbSet<T> dbColection, ref string name) where T : class + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + vm.Name = ""; + + PropertyInfo pi = typeof(T).GetProperty("Name"); + bool returnValue = false; + _notification.ShowModalDialog<AddItemDialogVM, Views.AddItemDialog>(vm, (x) => + { + if (String.IsNullOrEmpty(x.Name)) + { + returnValue = false; + return; + } + if (collection.Any(y => pi.GetValue(y).ToString().ToLower() == x.Name.ToLower())) + { + returnValue = false; + _notification.ShowError("The name already exists."); + return; + } + returnValue = true; + T newItem = (T)Activator.CreateInstance(typeof(T), new object[] { }); + pi.SetValue(newItem, x.Name); + dbColection.Add(newItem); + }, () => { }); + name = vm.Name; + return returnValue; + } + + private bool EditItemCollection<T>(ObservableCollection<T> collection, DbSet<T> dbColection, ref string name) where T : class + { + AddItemDialogVM vm = ViewModelLocator.AddItemDialogVM; + vm.Name = name; + string currentName = name; + + PropertyInfo pi = typeof(T).GetProperty("Name"); + bool returnValue = false; + _notification.ShowModalDialog<AddItemDialogVM, Views.AddItemDialog>(vm, (x) => + { + if (String.IsNullOrEmpty(x.Name) || currentName == x.Name) + { + returnValue = false; + return; + } + + if (collection.Any(y => pi.GetValue(y).ToString() == x.Name)) + { + returnValue = false; + _notification.ShowError("The name already exists."); + return; + } + returnValue = true; + }, () => { }); + name = vm.Name; + return returnValue; + } + + + private async void AddBrandItem(object obj) + { + string newName = ""; + if( AddItemToCollection( Brands, _active_context.YarnBrands, ref newName)) + { + await _active_context.SaveChangesAsync(); + Brands = _active_context.YarnBrands.ToObservableCollection(); + ActiveRMLExtension.YarnBrand = Brands.FirstOrDefault(b => b.Name == newName); + } + } + + private async void EditBrandItem(object obj) + { + string newName = ActiveRMLExtension.YarnBrand.Name; + if (EditItemCollection(Brands, _active_context.YarnBrands, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnBrand.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddEndUseItem(object ob) + { + string newName = ""; + if (AddItemToCollection(EndUse, _active_context.MediaPurposes, ref newName)) + { + await _active_context.SaveChangesAsync(); + EndUse = _active_context.MediaPurposes.ToObservableCollection(); + ActiveRML.MediaPurpose = EndUse.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditEndUseItem(object ob) + { + string newName = ActiveRML.MediaPurpose.Name; + if (EditItemCollection(EndUse, _active_context.MediaPurposes, ref newName)) + { + ActiveRML.LastUpdated = DateTime.UtcNow; + ActiveRML.MediaPurpose.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddApplicationItem(object ob) + { + string newName = ""; + if (AddItemToCollection(Applications, _active_context.YarnApplications, ref newName)) + { + await _active_context.SaveChangesAsync(); + Applications = _active_context.YarnApplications.ToObservableCollection(); + ActiveRMLExtension.YarnApplication = Applications.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditApplicationItem(object ob) + { + string newName = ActiveRMLExtension.YarnApplication.Name; + if (EditItemCollection(Applications, _active_context.YarnApplications, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnApplication.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddIndustrySectorItem(object ob) + { + string newName = ""; + if (AddItemToCollection(IndustrySector, _active_context.YarnIndustrysectors, ref newName)) + { + await _active_context.SaveChangesAsync(); + IndustrySector = _active_context.YarnIndustrysectors.ToObservableCollection(); + ActiveRMLExtension.YarnIndustrysector = IndustrySector.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditIndustrySectorItem(object ob) + { + string newName = ActiveRMLExtension.YarnIndustrysector.Name; + if (EditItemCollection(IndustrySector, _active_context.YarnIndustrysectors, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnIndustrysector.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddMaterialItem(object ob) + { + string newName = ""; + if (AddItemToCollection(Materials, _active_context.MediaMaterials, ref newName)) + { + await _active_context.SaveChangesAsync(); + Materials = _active_context.MediaMaterials.ToObservableCollection(); + ActiveRML.MediaMaterial = Materials.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditMaterialItem(object ob) + { + string newName = ActiveRML.MediaMaterial.Name; + if (EditItemCollection(Materials, _active_context.MediaMaterials, ref newName)) + { + ActiveRML.LastUpdated = DateTime.UtcNow; + ActiveRML.MediaMaterial.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddYarnTypeItem(object ob) + { + string newName = ""; + if (AddItemToCollection(YarnTypes, _active_context.YarnTypes, ref newName)) + { + await _active_context.SaveChangesAsync(); + YarnTypes = _active_context.YarnTypes.ToObservableCollection(); + ActiveRMLExtension.YarnType = YarnTypes.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditYarnTypeItem(object ob) + { + string newName = ActiveRMLExtension.YarnType.Name; + if (EditItemCollection(YarnTypes, _active_context.YarnTypes, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnType.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddSubFamilyItem(object ob) + { + string newName = ""; + if (AddItemToCollection(SubFamilies, _active_context.YarnSubFamilies, ref newName)) + { + await _active_context.SaveChangesAsync(); + SubFamilies = _active_context.YarnSubFamilies.ToObservableCollection(); + ActiveRMLExtension.YarnSubFamily = SubFamilies.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditSubFamilyItem(object ob) + { + string newName = ActiveRMLExtension.YarnSubFamily.Name; + if (EditItemCollection(SubFamilies, _active_context.YarnSubFamilies, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnSubFamily.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddFamilyItem(object ob) + { + string newName = ""; + if (AddItemToCollection(Family, _active_context.YarnFamilies, ref newName)) + { + await _active_context.SaveChangesAsync(); + Family = _active_context.YarnFamilies.ToObservableCollection(); + ActiveRMLExtension.YarnFamily = Family.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditFamilyItem(object ob) + { + string newName = ActiveRMLExtension.YarnFamily.Name; + if (EditItemCollection(Family, _active_context.YarnFamilies, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnFamily.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddGroupItem(object ob) + { + string newName = ""; + if (AddItemToCollection(Group, _active_context.YarnGroups, ref newName)) + { + await _active_context.SaveChangesAsync(); + Group = _active_context.YarnGroups.ToObservableCollection(); + ActiveRMLExtension.YarnGroup = Group.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditGroupItem(object ob) + { + string newName = ActiveRMLExtension.YarnGroup.Name; + if (EditItemCollection(Group, _active_context.YarnGroups, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnGroup.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddTexturingItem(object ob) + { + string newName = ""; + if (AddItemToCollection(Texturing, _active_context.YarnTexturings, ref newName)) + { + await _active_context.SaveChangesAsync(); + Texturing = _active_context.YarnTexturings.ToObservableCollection(); + ActiveRMLExtension.YarnTexturing = Texturing.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditTexturingItem(object ob) + { + string newName = ActiveRMLExtension.YarnTexturing.Name; + if (EditItemCollection(Texturing, _active_context.YarnTexturings, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnTexturing.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddGeometryItem(object ob) + { + string newName = ""; + if (AddItemToCollection(Geometry, _active_context.FiberShapes, ref newName)) + { + await _active_context.SaveChangesAsync(); + Geometry = _active_context.FiberShapes.ToObservableCollection(); + ActiveRML.FiberShape = Geometry.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditGeometryItem(object ob) + { + string newName = ActiveRML.FiberShape.Name; + if (EditItemCollection(Geometry, _active_context.FiberShapes, ref newName)) + { + ActiveRML.LastUpdated = DateTime.UtcNow; + ActiveRML.FiberShape.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddYarnWhiteShadeItem(object ob) + { + string newName = ""; + if (AddItemToCollection(YarnWhiteShade, _active_context.YarnWhiteShades, ref newName)) + { + await _active_context.SaveChangesAsync(); + YarnWhiteShade = _active_context.YarnWhiteShades.ToObservableCollection(); + ActiveRMLExtension.YarnWhiteShade = YarnWhiteShade.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditYarnWhiteShadeItem(object ob) + { + string newName = ActiveRMLExtension.YarnWhiteShade.Name; + if (EditItemCollection(YarnWhiteShade, _active_context.YarnWhiteShades, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnWhiteShade.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + private async void AddGlossLevelItem(object ob) + { + string newName = ""; + if (AddItemToCollection(GlossLevel, _active_context.YarnGlossLevels, ref newName)) + { + await _active_context.SaveChangesAsync(); + GlossLevel = _active_context.YarnGlossLevels.ToObservableCollection(); + ActiveRMLExtension.YarnGlossLevel = GlossLevel.FirstOrDefault(b => b.Name == newName); + } + } + private async void EditGlossLevelItem(object ob) + { + string newName = ActiveRMLExtension.YarnGlossLevel.Name; + if (EditItemCollection(GlossLevel, _active_context.YarnGlossLevels, ref newName)) + { + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRMLExtension.YarnGlossLevel.Name = newName; + await _active_context.SaveChangesAsync(); + } + } + + #endregion + + + public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) + { + _notification = notificationProvider; + _authentication = authentication; + _actionLogManager = actionLogManager; + + BackToThreadExtensionViewsCommand = new RelayCommand(BackToThreadExtensionViews, () => IsFree); + SaveCommand = new RelayCommand(Save, () => IsFree); + ManageRmlExtensionCommand = new RelayCommand(() => LoadActiveRMLExtension(SelectedRMLExtension.Guid), () => SelectedRMLExtension != null); + + + AddManufacturerItemCommand = new RelayCommand(AddManufacturerItem); + EditManufacturerItemCommand = new RelayCommand(EditManufacturerItem, () => ActiveRML.Manufacturer != ""); + + AddBrandItemCommand = new RelayCommand(AddBrandItem); + EditBrandItemCommand = new RelayCommand(EditBrandItem, () => ActiveRMLExtension.YarnBrand != null); + + AddEndUseItemCommand = new RelayCommand(AddEndUseItem); + EditEndUseItemCommand = new RelayCommand(EditEndUseItem); + + AddApplicationItemCommand = new RelayCommand(AddApplicationItem); + EditApplicationItemCommand = new RelayCommand(EditApplicationItem); + + AddIndustrySectorItemCommand = new RelayCommand(AddIndustrySectorItem); + EditIndustrySectorItemCommand = new RelayCommand(EditIndustrySectorItem); + + AddMaterialItemCommand = new RelayCommand(AddMaterialItem); + EditMaterialItemCommand = new RelayCommand(EditMaterialItem); + + AddYarnTypeItemCommand = new RelayCommand(AddYarnTypeItem); + EditYarnTypeItemCommand = new RelayCommand(EditYarnTypeItem); + + AddSubFamilyItemCommand = new RelayCommand(AddSubFamilyItem); + EditSubFamilyItemCommand = new RelayCommand(EditSubFamilyItem); + + AddFamilyItemCommand = new RelayCommand(AddFamilyItem); + EditFamilyItemCommand = new RelayCommand(EditFamilyItem); + + AddGroupItemCommand = new RelayCommand(AddGroupItem); + EditGroupItemCommand = new RelayCommand(EditGroupItem); + + AddTexturingItemCommand = new RelayCommand(AddTexturingItem); + EditTexturingItemCommand = new RelayCommand(EditTexturingItem); + + AddGeometryItemCommand = new RelayCommand(AddGeometryItem); + EditGeometryItemCommand = new RelayCommand(EditGeometryItem); + + AddYarnWhiteShadeItemCommand = new RelayCommand(AddYarnWhiteShadeItem); + EditYarnWhiteShadeItemCommand = new RelayCommand(EditYarnWhiteShadeItem); + + AddGlossLevelItemCommand = new RelayCommand(AddGlossLevelItem); + EditGlossLevelItemCommand = new RelayCommand(EditGlossLevelItem); + + } + + + public override void OnApplicationReady() + { + } + + + #region Loading + + private async Task LoadRmlExtentions() + { + var filter = Filter.ToStringOrEmpty().ToLower(); + + try + { + IsFree = false; + + using (_notification.PushTaskItem("Loading RmlExtentions...")) + { + if (_rmlExtentions_context != null) _rmlExtentions_context.Dispose(); + + _rmlExtentions_context = ObservablesContext.CreateDefault(); + + Brands = _rmlExtentions_context.YarnBrands.ToObservableCollection(); + _allUsers = await _rmlExtentions_context.Users.Include(x => x.Contact).ToListAsync(); + var q = (from c in _rmlExtentions_context.Rmls.Where(x => x.Name.ToLower().Contains(filter)) + join p in _rmlExtentions_context.RmlsExtensions on c.Guid equals p.RmlsGuid into ps + from p in ps.DefaultIfEmpty() + select new { RML = c, RMLExtesion = p }).Distinct().ToList().DistinctBy(x => x.RML.Guid) + .Select(x => new RmlExtensionModel() + { + RMLGuid = x.RML.Guid, + Guid = x.RMLExtesion == null? null : x.RMLExtesion.Guid, + Name = x.RML.Name, + Manufacturer = x.RML.Manufacturer, + Brand = x.RMLExtesion == null ? "" : (Brands.Where( y => y.Guid == x.RMLExtesion.YarnBrandGuid).Select( z => z.Name).FirstOrDefault()), + LinearDensity = (int) x.RML.FiberSize, + CreatedBy = x.RMLExtesion == null ? "" : _allUsers.SingleOrDefault(y => y.Guid == x.RMLExtesion.UsersGuid).Contact.FullName, + Created = x.RMLExtesion == null ? DateTime.Now : x.RMLExtesion.Created, + LastUpdated = x.RMLExtesion == null ? DateTime.Now : x.RMLExtesion.LastUpdated, + Status = x.RMLExtesion == null ? RMLExtensionStatus.New : x.RMLExtesion.RMLStatus, + Level = x.RMLExtesion == null ? RMLExtensionLevel.One : x.RMLExtesion.Level, + + }).ToList(); + RmlExtensions = q; + + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading RMLExtensions.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private void LoadRmlProperties() + { + Applications = _active_context.YarnApplications.ToObservableCollection(); + Brands = _active_context.YarnBrands.ToObservableCollection(); + YarnWhiteShade = _active_context.YarnWhiteShades.ToObservableCollection(); + EndUse = _active_context.MediaPurposes.ToObservableCollection(); + Family = _active_context.YarnFamilies.ToObservableCollection(); + Geometry = _active_context.FiberShapes.ToObservableCollection(); + GlossLevel = _active_context.YarnGlossLevels.ToObservableCollection(); + Group = _active_context.YarnGroups.ToObservableCollection(); + //Manufacturer = _active_context.YarnManufacturers.ToObservableCollection(); + Manufacturers = _active_context.YarnManufacturers.Select(x => x.Name).ToList(); + Units = _active_context.LinearMassDensityUnits.ToObservableCollection(); + Materials = _active_context.MediaMaterials.ToObservableCollection(); + SubFamilies = _active_context.YarnSubFamilies.ToObservableCollection(); + Texturing = _active_context.YarnTexturings.ToObservableCollection(); + YarnTypes = _active_context.YarnTypes.ToObservableCollection(); + IndustrySector = _active_context.YarnIndustrysectors.ToObservableCollection(); + Machines = ObservablesStaticCollections.Instance.Machines.Select(x => new MachineModel() + { + Guid = x.Guid, + Name = x.Name, + SerialNumber = x.SerialNumber + }).ToObservableCollection(); + + } + + private RmlsExtension GetNewRMLsExtension( string RML_Guid) + { + RmlsExtension rml_extention = new RmlsExtension(); + rml_extention.Created = DateTime.UtcNow; + rml_extention.RmlsGuid = RML_Guid; + rml_extention.UsersGuid = _authentication.CurrentUser.Guid; + //rml_extention.YarnManufacturer = Manufacturer.FirstOrDefault(); + rml_extention.YarnBrand = Brands.FirstOrDefault(); + rml_extention.Country = null; + //rml_extention.YarnEndUse = EndUse.FirstOrDefault(); + rml_extention.YarnApplication = Applications.FirstOrDefault(); + rml_extention.YarnIndustrysector = IndustrySector.FirstOrDefault(); + + //rml_extention.YarnMaterial = Materials.FirstOrDefault(); + rml_extention.YarnType = YarnTypes.FirstOrDefault(); + rml_extention.YarnSubFamily = SubFamilies.FirstOrDefault(); + rml_extention.YarnFamily = Family.FirstOrDefault(); + rml_extention.YarnGroup = Group.FirstOrDefault(); + rml_extention.YarnTexturing = Texturing.FirstOrDefault(); + rml_extention.YarnWhiteShade = YarnWhiteShade.FirstOrDefault(); + rml_extention.YarnGlossLevel = GlossLevel.FirstOrDefault(); + rml_extention.TwistTpm = 0; + rml_extention.YarnTwistDirections = TwistDirections.Unknown; + rml_extention.MinElongation = 0.0; + rml_extention.MaxElongation = 100.0; + rml_extention.MinMaxForceN = 0.0; + rml_extention.MaxMaxForceN = 100.0; + rml_extention.MinElasticity = 0.0; + rml_extention.MaxElasticity = 100.0; + rml_extention.MinTenacity = 0.0; + rml_extention.MaxTenacity = 100.0; + rml_extention.Finishing = "Lubrication"; + rml_extention.RMLStatus = RMLExtensionStatus.New; + rml_extention.Level = RMLExtensionLevel.One; + + return rml_extention; + } + + private async void LoadActiveRMLExtension(String guid) + { + using (_notification.PushTaskItem("Loading RML Extension...")) + { + try + { + IsFree = false; + + if (_active_context != null) + { + _active_context.Dispose(); + } + + _active_context = ObservablesContext.CreateDefault(); + LoadRmlProperties(); + + if (guid == null) + { + RmlsExtension rml_extention = GetNewRMLsExtension(SelectedRMLExtension.RMLGuid); + _active_context.RmlsExtensions.Add(rml_extention); + await _active_context.SaveChangesAsync(); + guid = rml_extention.Guid; + } + + ActiveRMLExtension = await new RmlExtensionsBuilder(_active_context) + .Set(guid) + .WithUser() + .BuildAsync(); + + ActiveRML = new RmlBuilder(_active_context) + .Set(SelectedRMLExtension.RMLGuid) + .Build(); + + if (!String.IsNullOrEmpty(ActiveRML.Manufacturer) && false == Manufacturers.Any(x => x == ActiveRML.Manufacturer)) + { + _active_context.YarnManufacturers.Add(new YarnManufacturer() { Name = ActiveRML.Manufacturer }); + await _active_context.SaveChangesAsync(); + Manufacturers.Add(ActiveRML.Manufacturer); + } + + var machineIdsHasTest = (from c in _active_context.ColorProcessParameters.Where(x => x.RmlsExtensionsGuid == guid) + select new { MichineGUID = c.MachineGuid }). + Union (from p in _active_context.RmlExtensionTestResults.Where(x => x.RmlsExtensionsGuid == guid) + select new { MichineGUID = p.MachineGuid }).DistinctBy(x => x).ToList(); + + if(machineIdsHasTest.Count > 0) + { + var MachineGuid = machineIdsHasTest.First().MichineGUID; + Machines.Where(x => machineIdsHasTest.Any(y => y.MichineGUID == x.Guid)).ToList().ForEach(x => x.HasRMLTest = true); + SelectedMachine = Machines.First(x => x.Guid == MachineGuid); + } + else + { + var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>(); + if(settings.LastVirtualMachineSerialNumber != null) + { + SelectedMachine = Machines.SingleOrDefault(x => x.SerialNumber == settings.LastVirtualMachineSerialNumber); + } + else + { + SelectedMachine = Machines.First(); + } + } + + ColorParametersVewVM = new ColorParametersVewVM(_notification, _actionLogManager); + ColorParametersVewVM.RMLExtemtionGUID = guid; + ColorParametersVewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null ; + ColorParametersVewVM.RMLGUID = ActiveRML.Guid; + + TestResultsViewVM = new TestResultsViewVM(_notification, _actionLogManager); + TestResultsViewVM.RMLExtemtionGUID = guid; + TestResultsViewVM.RMLGUID = ActiveRML.Guid; + TestResultsViewVM.SelectedMachineGUID = SelectedMachine != null ? SelectedMachine.Guid : null; + TestResultsViewVM.ThreadName = ActiveRML.Manufacturer; + + if (ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) + { + ColorParametersVewVM.SaveColorParameters -= UpdateStatus; + ColorParametersVewVM.SaveColorParameters += UpdateStatus; + TestResultsViewVM.SaveTestResults -= UpdateStatus; + TestResultsViewVM.SaveTestResults += UpdateStatus; + } + + View.NavigateTo(RMLExtensionNavigationView.RMLExtentionView); + + InvalidateRelayCommands(); + + IsFree = true; + } + catch (Exception ex) + { + //LogManager.Log($"Error loading RML '{ActiveRML.Name}'..."); + _notification.ShowError($"Error loading the selected thread.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + } + + private async void RefreshView(String guid, String rmlGuid) + { + try + { + IsFree = false; + + LoadRmlProperties(); + ActiveRML = ActiveRML = await new RmlBuilder(_active_context) + .Set(rmlGuid) + .BuildAsync(); + ActiveRMLExtension = await new RmlExtensionsBuilder(_active_context) + .Set(guid) + .WithUser() + .BuildAsync(); + + InvalidateRelayCommands(); + + IsFree = true; + } + catch (Exception ex) + { + //LogManager.Log($"Error loading RML '{ActiveRML.Name}'..."); + _notification.ShowError($"Error refresh after save the selected thread.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + #endregion + + #region event handlers + + private async void UpdateStatus(object sender, EventArgs e) + { + IsFree = false; + + try + { + ColorParametersVewVM.SaveColorParameters -= UpdateStatus; + TestResultsViewVM.SaveTestResults -= UpdateStatus; + ActiveRMLExtension.RMLStatus = RMLExtensionStatus.InProgress; + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + + await _active_context.SaveChangesAsync(); + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error saving Status of RML Extension"); + _notification.ShowError($"An error occurred while trying to save status of the current RML Extension.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private void SelectedMachineChanged() + { + if(ColorParametersVewVM != null) + { + ColorParametersVewVM.SelectedMachineGUID = SelectedMachine.Guid; + } + } + + #endregion + + #region Save + + /// <summary> + /// Saves this instance. + /// </summary> + private async void Save() + { + IsFree = false; + + try + { + using (_notification.PushTaskItem("Saving RML Extension...")) + { + if(ActiveRMLExtension.RMLStatus == RMLExtensionStatus.New) + { + ActiveRMLExtension.RMLStatus = RMLExtensionStatus.InProgress; + ColorParametersVewVM.SaveColorParameters -= UpdateStatus; + TestResultsViewVM.SaveTestResults -= UpdateStatus; + } + + ActiveRMLExtension.LastUpdated = DateTime.UtcNow; + ActiveRML.LastUpdated = DateTime.UtcNow; + + await _active_context.SaveChangesAsync(); + + // _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.RmlSaved, _authentication.CurrentUser, _rmlBeforeSave.Name, _rmlBeforeSave, rmlAfter, "RML saved using Machine Studio."); + + RefreshView(ActiveRMLExtension.Guid, ActiveRML.Guid); + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error saving RML Extension of RML{ActiveRML.Name}"); + _notification.ShowError($"An error occurred while trying to save the current RML Extension.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs new file mode 100644 index 000000000..4e7d84e7f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultViewVM.cs @@ -0,0 +1,201 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.ActionLogs; +using Tango.BL.DTO; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Notifications; +using Tango.SharedUI; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class TestResultViewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + #region Properties + + private string _threadName; + /// <summary> + /// Gets or sets the name of the thread. Using in print + /// </summary> + /// <value> + /// The name of the thread. + /// </value> + public string ThreadName + { + get { return _threadName; } + set + { + _threadName = value; + RaisePropertyChangedAuto(); + } + } + + + private bool _isSelected; + /// <summary> + /// Gets or sets a value indicating whether this instance is selected. + /// </summary> + public bool IsSelected + { + get { return _isSelected; } + set { _isSelected = value; RaisePropertyChangedAuto(); } + } + + private RmlExtensionTestResult _testResult; + + public RmlExtensionTestResult TestResult + { + get { return _testResult; } + set { _testResult = value; + RaisePropertyChangedAuto(); + } + } + + + #endregion + public RelayCommand ExportToFileCommand { get; set; } + + public TestResultViewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ExportToFileCommand = new RelayCommand(ExportToFile); + } + + #region save + // public void Save(ObservablesContext active_context) + //{ + // try + // { + // IsFree = false; + + // TestResult.LastUpdated = DateTime.UtcNow; + + // var RmlExtensionTestResultAfterChange = RmlExtensionTestResultDTO.FromObservable(TestResult); + + // active_context.SaveChanges(); + // } + // catch (Exception ex) + // { + // LogManager.Log(ex, "Could not update RmlExtension TestResult."); + // _notification.ShowError($"An error occurred while trying to save RmlExtension TestResult.\n{ex.Message}"); + // } + // finally + // { + // IsFree = true; + // } + //} + #endregion + + private void ExportToFile() + { + SaveFileDialog dlg = new SaveFileDialog(); + try + { + dlg.Title = $"Export excel calibration file for {TestResult.Name}"; + dlg.Filter = "Text Files|*.txt"; + dlg.DefaultExt = ".txt"; + dlg.FileName = $"RML_EXTENSION_{TestResult.Name}.txt"; + if (dlg.ShowDialog().Value) + { + using (StreamWriter outputFile = new StreamWriter(dlg.FileName)) + { + outputFile.WriteLine(String.Format($" {TestResult.Name.ToUpper()} ")); + outputFile.WriteLine(""); + outputFile.WriteLine(""); + outputFile.WriteLine(" Dryer temperature"); + outputFile.WriteLine(""); + outputFile.WriteLine(String.Format($" Dryer temperature : {TestResult.DryerTemperature.ToString()}")); + outputFile.WriteLine(String.Format($" Tunnel temperature : {TestResult.TunnelTemperature.ToString()}")); + outputFile.WriteLine(String.Format($" Tunnel flow : {TestResult.TunnelFlow.ToString()}")); + outputFile.WriteLine(String.Format($" Tunnel AVG temperature : {TestResult.TunnelAvgTemperature.ToString()}")); + outputFile.WriteLine(""); + outputFile.WriteLine(""); + outputFile.WriteLine(" Tension through the thread path"); + outputFile.WriteLine(""); + outputFile.WriteLine(String.Format($" Head : {TestResult.TensionHeadMin.ToString()} - {TestResult.TensionHeadMax.ToString()}")); + outputFile.WriteLine(String.Format($" After dryer : {TestResult.TensionAfterDryerMin.ToString()} - {TestResult.TensioinAfterDryerMax.ToString()}")); + outputFile.WriteLine(String.Format($" Winder : {TestResult.BtsrMin.ToString()} - {TestResult.BtsrMax.ToString()}")); + outputFile.WriteLine(String.Format($" BTSR : {TestResult.TensionHeadMin.ToString()} - {TestResult.TensionHeadMax.ToString()}")); + outputFile.WriteLine(String.Format($" Puller tension : {TestResult.PullerTensionMin.ToString()} - {TestResult.PullerTensionMax.ToString()}")); + outputFile.WriteLine(String.Format($" Winder exit tension: {TestResult.ExitTensionMin.ToString()} - {TestResult.ExitTensionMax.ToString()}")); + + outputFile.WriteLine(""); + outputFile.WriteLine(" Rubbing results"); + outputFile.WriteLine(""); + outputFile.WriteLine(" Color DeltaE CIE 100 % GS 100% DeltaETestResult CIE 200 % GS 200% "); + foreach (var rubbingResult in TestResult.RubbingResults) + { + StringBuilder sb = new StringBuilder(); + //sb.Append(" Color: "); + sb.Append($" { rubbingResult.TestResultColor.ToString()} "); + //sb.Append(" DeltaE CIE 100 % : "); + sb.Append($" { rubbingResult.DeltaeCie100.ToString()} "); + //sb.Append(" GS 100% : "); + sb.Append($" { rubbingResult.Gs100Min.ToString()}-{rubbingResult.Gs100Max.ToString()} "); + //sb.Append(" DeltaE CIE 200 % : "); + sb.Append($" { rubbingResult.DeltaeCie200.ToString()} "); + //sb.Append(" GS 200% : "); + sb.Append($" { rubbingResult.Gs200Min.ToString()}-{rubbingResult.Gs200Max.ToString()} "); + outputFile.WriteLine(sb); + } + outputFile.WriteLine(""); + outputFile.WriteLine(" Mechanical properties"); + outputFile.WriteLine(""); + outputFile.WriteLine(" %Color Color Load at Maximum Load(N) STDEV Percentage Strain at Maximum Load STDEV "); + foreach (var result in TestResult.TensileResults) + { + StringBuilder sb = new StringBuilder(); + //sb.Append(" % Color: "); + sb.Append($" { result.ColorPercent.ToString()}"); + //sb.Append(" Color : "); + sb.Append($" { result.TestResultColor.ToString()}"); + //sb.Append(" Load at Maximum Load(N) : "); + sb.Append($" { result.MaxLoad.ToString()}"); + //sb.Append(" STDEV : "); + sb.Append($" { result.StdevMaxLoad.ToString()}"); + //sb.Append(" Percentage Strain at Maximum Load: "); + sb.Append($" {result.StrainMaxLoad.ToString()}"); + //sb.Append(" STDEV : "); + sb.Append($" { result.StdevStrainMaxLoad.ToString()}"); + outputFile.WriteLine(sb); + } + outputFile.WriteLine(""); + outputFile.WriteLine(" Uniformity"); + outputFile.WriteLine(""); + outputFile.WriteLine(String.Format($" Zone1 : {TestResult.SeverityZone1Min.ToString()} - {TestResult.SeverityZone1Max.ToString()}")); + outputFile.WriteLine(String.Format($" Zone2 : {TestResult.SeverityZone2Min.ToString()} - {TestResult.SeverityZone2Max.ToString()}")); + outputFile.WriteLine(""); + outputFile.WriteLine(" COF"); + outputFile.WriteLine(""); + outputFile.WriteLine(" Thread name Lub Version COF Lub amount "); + outputFile.WriteLine(String.Format($" REF {TestResult.RefLubVersion} {TestResult.RefCof.ToString()} {TestResult.RefLub.ToString()}")); + outputFile.WriteLine(String.Format($" {ThreadName} {TestResult.ThreadLubVersion} {TestResult.ThreadCof.ToString()} {TestResult.ThreadLub.ToString()}")); + + outputFile.WriteLine(""); + outputFile.WriteLine(String.Format($" Comments: {TestResult.Comment}")); + outputFile.WriteLine(String.Format($" Conclusion: {TestResult.Conclusions}")); + outputFile.WriteLine(""); + outputFile.Flush(); + } + + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error exporting excel file " + dlg.FileName); + _notification.ShowError("An error occurred while trying to export the test result data."); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs new file mode 100644 index 000000000..cc3a49a23 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/TestResultsViewVM.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.AutoComplete.Editors; +using Tango.BL; +using Tango.BL.ActionLogs; +using Tango.BL.Builders; +using Tango.BL.DTO; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core; +using Tango.Core.Commands; +using Tango.Logging; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.ThreadExtensions.Models; +using Tango.Settings; +using Tango.SharedUI; + +namespace Tango.MachineStudio.ThreadExtensions.ViewModels +{ + public class TestResultsViewVM : ViewModel + { + private INotificationProvider _notification; + private IActionLogManager _actionLogManager; + + private ObservablesContext _active_context; + + public event EventHandler SaveTestResults; + + #region Properties + private SynchronizedObservableCollection<RmlExtensionTestResult> _selectedTestResults; + + public SynchronizedObservableCollection<RmlExtensionTestResult> SelectedTestResults + { + get { return _selectedTestResults; } + set { _selectedTestResults = value; } + } + + + private ObservableCollection<TestResultViewVM> _resultTabs; + + public ObservableCollection<TestResultViewVM> ResultTabs + { + get { return _resultTabs; } + set { _resultTabs = value; } + } + + private TestResultViewVM _selectedTab; + /// <summary> + /// Gets or sets the selected tab. + /// </summary> + public TestResultViewVM SelectedTab + { + get { return _selectedTab; } + set + { + _selectedTab = value; + RaisePropertyChangedAuto(); + + foreach (var tab in ResultTabs.Where(x => x != _selectedTab)) + { + tab.IsSelected = false; + } + + if (_selectedTab != null) + { + _selectedTab.IsSelected = true; + } + + //EnableRenderingForSelectedTabGraphs(); + } + } + + protected string _selectedMachineGuid; + /// <summary> + /// Gets or sets the selected machine. + /// </summary> + public String SelectedMachineGUID + { + get { return _selectedMachineGuid; } + set + { + if (value != null && _selectedMachineGuid != value) + { + _selectedMachineGuid = value; + SelectedMachineChanged(); + RaisePropertyChangedAuto(); + InvalidateRelayCommands(); + } + } + } + + private string _RMLExtentionGUID; + + public string RMLExtemtionGUID + { + get { return _RMLExtentionGUID; } + set { _RMLExtentionGUID = value; + OnRMLExtemtionGUIDChanged(); + } + } + + private string _threadName; + + public string ThreadName + { + get { return _threadName; } + set { _threadName = value; + RaisePropertyChangedAuto(); } + } + + private string _RMLGUID; + public string RMLGUID + { + get { return _RMLGUID; } + set + { + _RMLGUID = value; + } + } + + #endregion + + #region Commands + /// <summary> + /// Gets or sets the add tab command. + /// </summary> + public RelayCommand AddTabCommand { get; set; } + + /// <summary> + /// Gets or sets the remove tab command. + /// </summary> + public RelayCommand<TestResultViewVM> RemoveTabCommand { get; set; } + + /// <summary> + /// Gets or sets the rename tab command. + /// </summary> + public RelayCommand RenameTabCommand { get; set; } + + public RelayCommand ApplyToProcessParametersCommand { get; set; } + + public RelayCommand SaveCommand { get; set; } + + #endregion + + public TestResultsViewVM(INotificationProvider notification, IActionLogManager actionLogManager) + { + _notification = notification; + _actionLogManager = actionLogManager; + ResultTabs = new ObservableCollection<TestResultViewVM>(); + + AddTabCommand = new RelayCommand(() => AddNewTab()); + RemoveTabCommand = new RelayCommand<TestResultViewVM>(RemoveTab); + RenameTabCommand = new RelayCommand(RenameTab); + + ApplyToProcessParametersCommand = new RelayCommand(ApplyToProcessParameters); + SaveCommand = new RelayCommand(Save, () => IsFree); + } + + #region Tabs modification + + /// <summary> + /// Removes the specified tab. + /// </summary> + /// <param name="tab">The tab.</param> + private void RemoveTab(TestResultViewVM tab) + { + if (ResultTabs.Count == 1) + return; + if (_notification.ShowQuestion("Are you sure you want to delete the selected tab?")) + { + _active_context.RubbingResults.RemoveRange(tab.TestResult.RubbingResults); + tab.TestResult.RubbingResults = null; + + _active_context.TensileResults.RemoveRange(tab.TestResult.TensileResults); + tab.TestResult.TensileResults = null; + + _active_context.RmlExtensionTestResults.Remove(tab.TestResult); + + ResultTabs.Remove(tab); + SelectedTab = ResultTabs.LastOrDefault(); + _active_context.SaveChanges(); + + } + } + + /// <summary> + /// Adds a new tab. + /// </summary> + private bool AddNewTab(String name = null) + { + if (ResultTabs.Count > 7) + { + //_notification.ShowError("Cannot exceed the maximum number of 8 tabs. You can remove a tab, or create a new project."); + return false; + } + + if (name == null) + { + name = _notification.ShowTextInput("Enter tab name", "Tab Name", "Test"); + } + + if (!String.IsNullOrWhiteSpace(name)) + { + var tab = CreateNewTestResultVM(name, (ResultTabs.Count + 1)); + ResultTabs.Add(tab); + _active_context.RmlExtensionTestResults.Add(tab.TestResult); + SelectedTab = tab; + return true; + } + else + { + return false; + } + } + + /// <summary> + /// Renames the tab. + /// </summary> + /// <param name="tab">The tab.</param> + private void RenameTab() + { + if (SelectedTab != null) + { + var name = _notification.ShowTextInput("Enter tab name", "Tab Name", SelectedTab.TestResult.Name); + + if (!String.IsNullOrWhiteSpace(name)) + { + SelectedTab.TestResult.Name = name; + } + } + } + #endregion + + #region Loading test results + + private void OnRMLExtemtionGUIDChanged() + { + ResultTabs.Clear(); + SelectedTab = null; + } + + private void SelectedMachineChanged() + { + ResultTabs.Clear(); + SelectedTab = null; + LoadTestResults(); + } + public async void LoadTestResults() + { + if (String.IsNullOrEmpty(SelectedMachineGUID)) + { + _notification.ShowWarning(LogManager.Log($" Please, select machine.", LogCategory.Warning)); + return; + } + + try + { + IsFree = false; + if (_active_context != null) + { + _active_context.Dispose(); + } + _active_context = ObservablesContext.CreateDefault(); + ResultTabs.Clear(); + LogManager.Log("Loading selected test results..."); + + using (_notification.PushTaskItem("Loading Test Results Parameters ...")) + { + var testResults = await new RMLExtensionTestResultsCollectionBuilder(_active_context).SetAll().ForRMLExtension(RMLExtemtionGUID).ForMachine(SelectedMachineGUID).WithRubbingAndTensileResults().BuildAsync(); + SelectedTestResults = testResults.OrderBy(x => x.ResultIndex).ToSynchronizedObservableCollection(); + foreach (var result in SelectedTestResults) + { + ResultTabs.Add(new TestResultViewVM(_notification, _actionLogManager) { TestResult = result, ThreadName = ThreadName }); + if (result.ResultIndex == 1) + { + SelectedTab = ResultTabs[ResultTabs.Count - 1]; + } + } + if (ResultTabs.Count == 0) + { + SelectedTab = CreateNewTestResultVM("Untitled", 1); + ResultTabs.Add(SelectedTab); + _active_context.RmlExtensionTestResults.Add(SelectedTab.TestResult); + await _active_context.SaveChangesAsync(); + } + } + IsFree = true; + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error loading TestResults.\n{ex.FlattenMessage()}"); + } + finally + { + IsFree = true; + } + } + + private TestResultViewVM CreateNewTestResultVM(string name, int index) + { + TestResultViewVM newtab = new TestResultViewVM(_notification, _actionLogManager) { ThreadName = ThreadName }; + newtab.TestResult = new RmlExtensionTestResult() { RmlsExtensionsGuid = RMLExtemtionGUID, MachineGuid = SelectedMachineGUID, ResultIndex = index, Name = name, BtsrMax = 0.0, BtsrMin = 0.0, DryerTemperature = 0, TunnelTemperature = 0, TunnelFlow = 0.0, TunnelAvgTemperature = 0.0, TensionHeadMax = 0.0, + TensionHeadMin = 0.0, TensioinAfterDryerMax = 0.0, TensionAfterDryerMin = 0.0, TensionWinderMax = 0.0, TensionWinderMin = 0.0, PullerTensionMax = 0.0, PullerTensionMin = 0.0, ExitTensionMax = 0.0, ExitTensionMin = 0.0, SeverityZone1Max = 0.0, SeverityZone1Min = 0.0, SeverityZone2Max = 0.0, SeverityZone2Min = 0.0, + RefLubVersion="", RefCof = 0.0, RefLub = 0.0, ThreadLubVersion = "", ThreadCof = 0.0, ThreadLub = 0.0, Conclusions="", Comment=""}; + var rubbingresults = new SynchronizedObservableCollection<RubbingResult>(); + rubbingresults.Add(new RubbingResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.CYAN }); + rubbingresults.Add(new RubbingResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.MAGENTA }); + rubbingresults.Add(new RubbingResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.YELLOW }); + rubbingresults.Add(new RubbingResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.BLACK }); + newtab.TestResult.RubbingResults = rubbingresults; + + var tensileresults = new SynchronizedObservableCollection<TensileResult>(); + tensileresults.Add(new TensileResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.CYAN, ColorPercent = 100 }); + tensileresults.Add(new TensileResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.BLACK, ColorPercent = 100 }); + tensileresults.Add(new TensileResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.CYAN, ColorPercent = 200 }); + tensileresults.Add(new TensileResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.BLACK, ColorPercent = 200 }); + tensileresults.Add(new TensileResult() { RmlExtensionTestResultsGuid = newtab.TestResult.Guid, TestResultColor = TestResultColors.WHITE, ColorPercent = null }); + newtab.TestResult.TensileResults = tensileresults; + + return newtab; + } + + #endregion + #region Save + + public async void ApplyToProcessParameters() + { + try { + if (RMLGUID == null) + return; + + using (var context = ObservablesContext.CreateDefault()) + { + var rml = await new RmlBuilder(context) + .Set(RMLGUID) + .WithActiveParametersGroup() + .BuildAsync(); + if (rml == null || rml.ProcessParametersTablesGroups.ToList().Count == 0) + { + _notification.ShowError("Could not save process parameters an RML with no process group."); + return; + } + + var activeProcessParametersGroup = rml.ProcessParametersTablesGroups.ToList().SingleOrDefault(x => x.Active); + if(activeProcessParametersGroup != null) + { + + var processParametersTables = activeProcessParametersGroup.ProcessParametersTables.OrderBy(x => x.TableIndex).ToSynchronizedObservableCollection().FirstOrDefault(); + processParametersTables.DryerZone1Temp = SelectedTab.TestResult.DryerTemperature == null? 0 : (double)SelectedTab.TestResult.DryerTemperature; + processParametersTables.RBlowerFlow = SelectedTab.TestResult.TunnelFlow == null ? 0 : (double)SelectedTab.TestResult.TunnelFlow; + processParametersTables.RBlowerTemp = SelectedTab.TestResult.TunnelFlow == null ? 0 : (double)SelectedTab.TestResult.TunnelFlow; ; + processParametersTables.LBlowerFlow = SelectedTab.TestResult.TunnelTemperature == null ? 0 : (double)SelectedTab.TestResult.TunnelTemperature; ; + processParametersTables.LBlowerTemp = SelectedTab.TestResult.TunnelTemperature == null ? 0 : (double)SelectedTab.TestResult.TunnelTemperature; ; + await context.SaveChangesAsync(); + } + } + } + catch(Exception ex) + { + LogManager.Log(ex, "Could not save process parameters."); + _notification.ShowError($"An error occurred while trying to save process parameters.\n{ex.Message}"); + } + } + + public async void Save() + { + if (String.IsNullOrEmpty(SelectedMachineGUID)) + { + _notification.ShowWarning(LogManager.Log($"Could not save Test Results. Please, select machine.", LogCategory.Warning)); + return; + } + try + { + IsFree = false; + await Task.Factory.StartNew(() => + { + foreach (var tab in ResultTabs) + { + tab.TestResult.LastUpdated = DateTime.UtcNow; + } + _active_context.SaveChanges(); + }); + + LoadTestResults(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not save test results."); + _notification.ShowError($"An error occurred while trying to save test results.\n{ex.Message}"); + } + finally + { + IsFree = true; + EventHandler handler = SaveTestResults; + handler?.Invoke(this, new EventArgs()); + } + } + + #endregion + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml new file mode 100644 index 000000000..c529eabe0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml @@ -0,0 +1,21 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.AddItemDialog" + 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.ThreadExtensions.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + mc:Ignorable="d" + d:DesignHeight="650" d:DesignWidth="800" Background="{StaticResource Dialog.Background}" Foreground="{StaticResource MainWindow.Foreground}" d:DataContext="{d:DesignInstance Type=vm:AddItemDialogVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.AddItemDialogVM}"> + <Grid> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock Text="New Item Name" VerticalAlignment="Center" Margin="0 20 0 0" FontSize="20"></TextBlock> + <TextBox Name="ItemlName" TextAlignment="Left" FontSize="21" MinWidth="250" Margin="0 20 10 10" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" ></TextBox> + <StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal"> + <Button Name="AddItem" Command="{Binding SaveCommand}" Width="Auto" HorizontalAlignment="Right" Margin="0 40 10 10">SAVE</Button> + <Button Command="{Binding CancelCommand}" Width="Auto" HorizontalAlignment="Right" Margin="0 40 10 10">CANCEL</Button> + </StackPanel> + </StackPanel> + </Grid> +</UserControl>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.xaml.cs new file mode 100644 index 000000000..6bd81343e --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/AddItemDialog.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.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for AddItemDialog.xaml + /// </summary> + public partial class AddItemDialog : UserControl + { + public AddItemDialog() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorParametersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorParametersView.xaml new file mode 100644 index 000000000..697289604 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorParametersView.xaml @@ -0,0 +1,462 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.ColorParametersView" + 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.ThreadExtensions.Views" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:converters="clr-namespace:Tango.MachineStudio.ThreadExtensions.Converters" + xmlns:enumerators="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:oxy="http://oxyplot.org/wpf" + xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="1200" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + + <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" /> + <converters:ColorNameToBrushConverter x:Key="ColorNameToBrushConverter"/> + + <Style x:Key="CellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsHitTestVisible" Value="false"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="HideUpDownButtons" Value="true"/> + <Setter Property="FontSize" Value="14"/> + </Style> + + <Style x:Key="FactorCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsHitTestVisible" Value="false"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="HideUpDownButtons" Value="true"/> + <Setter Property="Margin" Value=" 10 0 0 0"/> + <Setter Property="FontSize" Value="14"/> + </Style> + + <Style x:Key="EditableCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Center"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="FontSize" Value="14"/> + </Style> + + <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> + + </UserControl.Resources> + + <Grid x:Name="contentGrid" DataContext="{Binding ColorParametersVewVM}"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="2*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <DockPanel Grid.Column="0"> + <UniformGrid Columns="2" FirstColumn="0" Name="uniformGrid1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" > + + <DockPanel Grid.Column="0" Grid.Row="0" x:Name="CyanPanel"> + <Border DockPanel.Dock="Top" Background="LightCyan" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Padding="2" Height="26" Width="140" Background="Transparent" Command="{Binding ImportCyanDataCommand}" ToolTip="Import Cyan data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE CYAN</TextBlock> + + </DockPanel> + </Grid> + </Border> + + <Grid Margin="10 20 0 10"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="20 30 10 0"> + <StackPanel Orientation="Vertical"> + + <DataGrid HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="340" SelectionMode="Single" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" ItemsSource="{Binding CyanProcessData}" Margin="0 0 0 50"> + + <DataGrid.Columns> + <mahapps:DataGridNumericUpDownColumn Header="nl/cm" Minimum="0" Maximum="100000" Binding="{Binding InkNlCm}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L,Delay=100 ,UpdateSourceTrigger=LostFocus}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A,Delay=100, UpdateSourceTrigger=LostFocus}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B ,Delay=100, UpdateSourceTrigger=LostFocus}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + </StackPanel> + </Grid> + + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Margin="10 0 0 0"> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot Title="Cyan" TitleFontSize="14" x:Name="CyanPlotControl" Margin="0 0 10 0" Background="Transparent" > + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding CyanPlot.Points}" Color="Cyan" MarkerFill="SteelBlue" MarkerType="Circle" /> + <oxy:LineSeries ItemsSource="{Binding CyanPlot.Target100Points}" Color="#C5E14141" LineStyle="LongDash" /> + <oxy:LineSeries ItemsSource="{Binding CyanPlot.Target200Points}" Color="#C5E14141" LineStyle="Dash" /> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "nl/cm" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" /> + <oxy:LinearAxis Position="Left" Title = "Lab" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding CyanPlot.From}" Maximum="{Binding CyanPlot.To}" /> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + </Grid> + </Grid> + </DockPanel> + <DockPanel Grid.Column="1"> + <Border DockPanel.Dock="Top" Background="#FC63FC" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Height="26" Padding="2" Width="140" Background="Transparent" Command="{Binding ImportMagentaDataCommand}" ToolTip="Import Magenta data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE MAGENTA</TextBlock> + </DockPanel> + </Grid> + </Border> + <Grid Margin="10 20 0 10"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="20 30 10 0"> + <StackPanel Orientation="Vertical"> + + <DataGrid HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="340" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" ItemsSource="{Binding MagentaProcessData}" Margin="0 0 0 50"> + + <DataGrid.Columns> + <mahapps:DataGridNumericUpDownColumn Header="nl/cm" Minimum="0" Maximum="100000" Binding="{Binding InkNlCm}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + </StackPanel> + </Grid> + + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Margin="10 0 0 0"> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot Title="Magenta" TitleFontSize="14" x:Name="MagentaPlotControl" Margin="0 0 10 0" Background="Transparent" > + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding MagentaPlot.Points}" Color="Magenta" MarkerFill="SteelBlue" MarkerType="Circle" /> + <oxy:LineSeries ItemsSource="{Binding MagentaPlot.Target100Points}" Color="#C5E14141" LineStyle="LongDash" /> + <oxy:LineSeries ItemsSource="{Binding MagentaPlot.Target200Points}" Color="#C5E14141" LineStyle="Dash" /> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "nl/cm" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" /> + <oxy:LinearAxis Position="Left" Title = "Lab" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding MagentaPlot.From}" Maximum="{Binding MagentaPlot.To}" /> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + </Grid> + </Grid> + </DockPanel > + <DockPanel Grid.Column="0" Grid.Row="1" x:Name="YellowPanel"> + <Border DockPanel.Dock="Top" Background="LightYellow" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Height="26" Padding="2" Width="140" Background="Transparent" Command="{Binding ImportYellowDataCommand}" ToolTip="Import Yellow data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2"> + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE YELLOW</TextBlock> + </DockPanel> + </Grid> + </Border> + <Grid Margin="10 20 0 10"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="20 30 10 0"> + <StackPanel Orientation="Vertical"> + <DataGrid HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="340" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" ItemsSource="{Binding YellowProcessData}" Margin="0 0 0 50"> + <DataGrid.Columns> + <mahapps:DataGridNumericUpDownColumn Header="nl/cm" Minimum="0" Maximum="10000" Binding="{Binding InkNlCm}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + </StackPanel> + </Grid> + + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Margin="10 0 0 0"> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot Title="Yellow" TitleFontSize="14" x:Name="YellowPlotControl" Margin="0 0 10 0" Background="Transparent" > + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding YellowPlot.Points}" Color="Yellow" MarkerFill="SteelBlue" MarkerType="Circle" /> + <oxy:LineSeries ItemsSource="{Binding YellowPlot.Target100Points}" Color="#C5E14141" LineStyle="LongDash" /> + <oxy:LineSeries ItemsSource="{Binding YellowPlot.Target200Points}" Color="#C5E14141" LineStyle="Dash" /> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "nl/cm" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" /> + <oxy:LinearAxis Position="Left" Title = "Lab" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding YellowPlot.From}" Maximum="{Binding YellowPlot.To}" /> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + </Grid> + </Grid> + </DockPanel> + <DockPanel Grid.Column="1" Grid.Row="1"> + <Border DockPanel.Dock="Top" Background="DarkGray" Margin="20 0 0 0 " Padding="5" CornerRadius="5" Height="40" VerticalAlignment="Top"> + <Border.Effect> + <DropShadowEffect Opacity="0.4" /> + </Border.Effect> + <Grid> + <DockPanel> + <Button DockPanel.Dock="Right" HorizontalAlignment="Left" Height="26" Padding="2" Width="140" Background="Transparent" Command="{Binding ImportBlackDataCommand}" ToolTip="Import Black data " Margin="0 0 10 0" BorderBrush="{StaticResource TransparentBackgroundBrush200}" BorderThickness="1 1 0.8 2" > + <TextBlock FontSize="14" Foreground="{StaticResource MainWindow.Foreground}">IMPORT DATA</TextBlock> + </Button> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 4 0 0" FontSize="16" Padding="0">LIQUID TYPE BLACK</TextBlock> + </DockPanel> + </Grid> + + </Border> + <Grid Margin="10 20 0 10"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + + <Grid HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0" Margin="20 30 10 0"> + <StackPanel Orientation="Vertical" > + + <DataGrid HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="340" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" ItemsSource="{Binding BlackProcessData}" Margin="0 0 0 50"> + + <DataGrid.Columns> + <mahapps:DataGridNumericUpDownColumn Header="nl/cm" Minimum="0" Maximum="10000" Binding="{Binding InkNlCm}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + </StackPanel> + </Grid> + + <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0" Margin="10 0 0 0"> + <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="{StaticResource DarkGrayBrush}" CornerRadius="5"> + <oxy:Plot Title=" Black" TitleFontSize="14" x:Name="BlackPlotControl" Margin="0 0 10 0" Background="Transparent" > + <oxy:Plot.Series > + <oxy:LineSeries ItemsSource="{Binding BlackPlot.Points}" Color="Black" MarkerFill="SteelBlue" MarkerType="Circle" /> + <oxy:LineSeries ItemsSource="{Binding BlackPlot.Target100Points}" Color="#A1E14141" LineStyle="LongDash" /> + <oxy:LineSeries ItemsSource="{Binding BlackPlot.Target200Points}" Color="#A1E14141" LineStyle="Dash" /> + </oxy:Plot.Series> + <oxy:Plot.Axes> + <oxy:LinearAxis Position="Bottom" Title = "nl/cm" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" /> + <oxy:LinearAxis Position="Left" Title = "Lab" MajorGridlineStyle="Solid" MinorGridlineStyle="Dot" IsZoomEnabled="True" Minimum="{Binding BlackPlot.From}" Maximum="{Binding BlackPlot.To}" /> + </oxy:Plot.Axes> + </oxy:Plot> + </Border> + </Grid> + </Grid> + </DockPanel> + </UniformGrid> + </DockPanel> + <DockPanel Grid.Column="1"> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" HorizontalAlignment="Right"> + <Button HorizontalAlignment="Right" VerticalAlignment="Center" Height="35" Width="170" ToolTip="Apply to RML Liquid factors" Margin="0 0 20 0" Command="{Binding SaveFactorsCommand}" > + <TextBlock FontSize="14" >Save Factors</TextBlock> + </Button> + <Button HorizontalAlignment="Right" Width="170" Height="35" VerticalAlignment="Center" Command="{Binding SaveCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">SAVE</TextBlock> + </StackPanel> + </Button> + +</StackPanel> + + + <StackPanel Orientation="Vertical" Margin="40 20 0 0"> + <Border BorderBrush="{StaticResource Statistics.BorderBrush}" BorderThickness="1"> + <UniformGrid Rows="2" Columns="4" x:Name="whitePointsGrid" DataContext="{Binding SelectedColorProcessParameter}"> + <Border BorderThickness="0 0 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock></TextBlock> + </Border> + <Border BorderThickness="1 0 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0" Foreground="{StaticResource GrayBrush200}">L</TextBlock> + </Border> + <Border BorderThickness="1 0 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0" Foreground="{StaticResource GrayBrush200}">A</TextBlock> + </Border> + <Border BorderThickness="1 0 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0" Foreground="{StaticResource GrayBrush200}">B</TextBlock> + </Border> + <Border BorderThickness="0 1 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0" Foreground="{StaticResource GrayBrush200}">White point</TextBlock> + </Border> + <Border BorderThickness="1 1 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown Minimum="-500" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding Path=DataContext.ActiveRML.WhitePointL, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" FontSize="14" Margin="10 0 0 0"></mahapps:NumericUpDown> + </Border> + <Border BorderThickness="1 1 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown Minimum="-500" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding Path=DataContext.ActiveRML.WhitePointA,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" FontSize="14" Margin="10 0 0 0"></mahapps:NumericUpDown> + </Border> + <Border BorderThickness="1 1 0 0" Background="Transparent" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown Minimum="-500" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HasDecimals="True" HorizontalContentAlignment="Left" Value="{Binding Path=DataContext.ActiveRML.WhitePointB,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" FontSize="14" Margin="10 0 0 0"></mahapps:NumericUpDown> + </Border> + </UniformGrid> + </Border> + + + <DataGrid x:Name="Factor100Grid" HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="250" RowHeight="26" Padding="0" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding Factor100ProcessData}" Margin="0 20 0 20"> + <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> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn Header="Factor 100%" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Border BorderThickness="0" Background="{Binding FactorColor, Converter={StaticResource ColorNameToBrushConverter}}"> + <mahapps:NumericUpDown Minimum="0" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" VerticalContentAlignment="Top" Margin="0" Padding="0" + HideUpDownButtons="True" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding InkNlCm,Mode=TwoWay}" FontSize="14"></mahapps:NumericUpDown> + </Border> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + + <DataGrid x:Name="Factor200Grid" HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="250" RowHeight="26" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding Factor200ProcessData}" Margin="0 10 0 20"> + <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> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> + <Setter Property="FontSize" Value="14"/> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn Header="Factor 200%" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Border BorderThickness="0" Background="{Binding FactorColor, Converter={StaticResource ColorNameToBrushConverter}}"> + <mahapps:NumericUpDown Minimum="0" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" + HideUpDownButtons="True" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding InkNlCm,Mode=TwoWay}" FontSize="14"></mahapps:NumericUpDown> + </Border> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + + <DataGrid x:Name="MinInkUptakeGrid" HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="250" RowHeight="26" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding MinInkUptake}" Margin="0 10 0 20"> + <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> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> + <Setter Property="FontSize" Value="14"/> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn Header="Min Ink Uptake" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Border BorderThickness="0" Background="{Binding FactorColor, Converter={StaticResource ColorNameToBrushConverter}}"> + <mahapps:NumericUpDown Minimum="0" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" + HideUpDownButtons="True" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding InkNlCm,Mode=TwoWay}" FontSize="14"></mahapps:NumericUpDown> + </Border> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}"/> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + + <DataGrid x:Name="MaxInkUptakeGrid" HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="250" RowHeight="26" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding MaxInkUptake}" Margin="0 10 0 20"> + <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> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> + <Setter Property="FontSize" Value="14"/> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn Header="Max Ink Uptake" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Border BorderThickness="0" Background="{Binding FactorColor, Converter={StaticResource ColorNameToBrushConverter}}"> + <mahapps:NumericUpDown Minimum="0" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" + HideUpDownButtons="True" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding InkNlCm,Mode=TwoWay}" FontSize="14"></mahapps:NumericUpDown> + </Border> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + <mahapps:DataGridNumericUpDownColumn Header="L" Minimum="0" Maximum="100" Binding="{Binding L}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="A" Minimum="-128" Maximum="127" Binding="{Binding A}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + <mahapps:DataGridNumericUpDownColumn Header="B" Minimum="-128" Maximum="127" Binding="{Binding B}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource FactorCellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + </DataGrid.Columns> + </DataGrid> + </StackPanel> + </DockPanel> + </Grid> + +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorParametersView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorParametersView.xaml.cs new file mode 100644 index 000000000..4e6a8c048 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ColorParametersView.xaml.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +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; +using Tango.MachineStudio.ThreadExtensions.ViewModels; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for ColorParametersView.xaml + /// </summary> + public partial class ColorParametersView : UserControl + { + public ColorParametersView() + { + InitializeComponent(); + this.Loaded += ColorParametersView_Loaded; + } + + private void ColorParametersView_Loaded(object sender, RoutedEventArgs e) + { + if (contentGrid != null && contentGrid.DataContext is ColorParametersVewVM) + { + ColorParametersVewVM vm = (ColorParametersVewVM)contentGrid.DataContext; + vm.CyanPlot.PlotControl = CyanPlotControl; + vm.MagentaPlot.PlotControl = MagentaPlotControl; + vm.YellowPlot.PlotControl = YellowPlotControl; + vm.BlackPlot.PlotControl = BlackPlotControl; + vm.IsViewLoaded = true; + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml new file mode 100644 index 000000000..01e7d7960 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml @@ -0,0 +1,32 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.ComboboxEditable" + 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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800"> + <Grid> + <DockPanel> + <Button Margin="2 0 0 0" Command="{Binding EditCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Pencil" Height="12" Foreground="{StaticResource BlueBrush100}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.6" ScaleY="1.6"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + + <Button Margin="2 0 0 0" Command="{Binding AddCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" DockPanel.Dock="Right" Padding="0" Background="Transparent" BorderThickness="0"> + <materialDesign:PackIcon Kind="Plus" Height="12" Foreground="{StaticResource RedBrush100}" Width="12" FontWeight="UltraBold"> + <materialDesign:PackIcon.LayoutTransform> + <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.6" ScaleY="1.6"/> + </materialDesign:PackIcon.LayoutTransform> + </materialDesign:PackIcon> + </Button> + + <ComboBox DockPanel.Dock="Left" VerticalAlignment="Center" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor},Path=ItemsSource}" SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=UserControl}}" DisplayMemberPath="{Binding RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor},Path=DisplayMemberPath}" IsEditable="False" Margin="0 0 0 0" Width="Auto" /> + + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml.cs new file mode 100644 index 000000000..251241159 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ComboboxEditable.xaml.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections; +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; +using Tango.Core.Commands; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for ComboboxEditable.xaml + /// </summary> + public partial class ComboboxEditable : UserControl + { + public ComboboxEditable() + { + InitializeComponent(); + } + + + public IEnumerable ItemsSource + { + get { return (IEnumerable)GetValue(ItemsSourceProperty); } + set { SetValue(ItemsSourceProperty, value); } + } + + // Using a DependencyProperty as the backing store for ItemsSource. This enables animation, styling, binding, etc... + public static readonly DependencyProperty ItemsSourceProperty = + DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(ComboboxEditable), new PropertyMetadata(null)); + + + + public object SelectedItem + { + get { return (object)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + + // Using a DependencyProperty as the backing store for SelectedItem. This enables animation, styling, binding, etc... + public static readonly DependencyProperty SelectedItemProperty = + DependencyProperty.Register("SelectedItem", typeof(object), typeof(ComboboxEditable), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); + + + + + public string DisplayMemberPath + { + get { return (string)GetValue(DisplayMemberPathProperty); } + set { SetValue(DisplayMemberPathProperty, value); } + } + + public static readonly DependencyProperty DisplayMemberPathProperty = + DependencyProperty.Register("DisplayMemberPath", typeof(string), typeof(ComboboxEditable), new PropertyMetadata("")); + + + + public RelayCommand AddCommand + { + get { return (RelayCommand)GetValue(AddCommandProperty); } + set { SetValue(AddCommandProperty, value); } + } + + // Using a DependencyProperty as the backing store for DeleteCommand. This enables animation, styling, binding, etc... + public static readonly DependencyProperty AddCommandProperty = + DependencyProperty.Register("AddCommand", typeof(RelayCommand), typeof(ComboboxEditable)); + + public RelayCommand EditCommand + { + get { return (RelayCommand)GetValue(EditCommandProperty); } + set { SetValue(EditCommandProperty, value); } + } + + // Using a DependencyProperty as the backing store for DeleteCommand. This enables animation, styling, binding, etc... + public static readonly DependencyProperty EditCommandProperty = + DependencyProperty.Register("EditCommand", typeof(RelayCommand), typeof(ComboboxEditable)); + + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml new file mode 100644 index 000000000..27bffbebb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml @@ -0,0 +1,63 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.MachineTestResultsView" + 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.ThreadExtensions.Views" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="1200" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + + <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" /> + </UserControl.Resources> + + <Grid> + <DockPanel> + <StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> + <TextBlock Margin="40 10" FontSize="20" FontWeight="SemiBold" FontStyle="Italic">TARGET MACHINE</TextBlock> + + <controls:SearchComboBox FontSize="20" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" materialDesign:HintAssist.Hint="Serial Number" Width="280" HorizontalContentAlignment="Stretch" SearchProperty="Name" ItemsSource="{Binding Machines}"> + <controls:SearchComboBox.ItemTemplate> + <DataTemplate> + <StackPanel> + <TextBlock Text="{Binding SerialNumber}" FontWeight="Bold" FontStyle="Italic"/> + <TextBlock FontSize="11" Text="{Binding Name}" Foreground="Gray"/> + </StackPanel> + <DataTemplate.Triggers> + <DataTrigger Binding="{Binding HasRMLTest}" Value="True"> + <Setter Property="TextBlock.Foreground" Value="red"/> + </DataTrigger> + </DataTemplate.Triggers> + </DataTemplate> + </controls:SearchComboBox.ItemTemplate> + </controls:SearchComboBox> + </StackPanel> + <Grid IsEnabled="{Binding IsFree}" Margin="0 30 20 10" > + <TabControl Background="Transparent" Margin="0,-50,0,0" x:Name="processTabControl" Padding="0 25 0 0" > + <TabControl.Resources> + <Style TargetType="TabPanel"> + <Setter Property="HorizontalAlignment" Value="Center"/> + </Style> + <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}"> + <Setter Property="Padding" Value="20,2"></Setter> + </Style> + </TabControl.Resources> + <TabItem Header="COLOR PARAMETERS" Margin="20 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:ColorParametersView/> + </TabItem> + <TabItem Header="TEST RESULTS" Margin="20 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:TestResultsView /> + </TabItem> + </TabControl> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.xaml.cs new file mode 100644 index 000000000..0af378b52 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MachineTestResultsView.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.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for MachineTestResults.xaml + /// </summary> + public partial class MachineTestResultsView : UserControl + { + public MachineTestResultsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MainView.xaml new file mode 100644 index 000000000..d40c3a05d --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MainView.xaml @@ -0,0 +1,19 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.MainView" + 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.ThreadExtensions.Views" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + <Grid IsEnabled="{Binding IsFree}"> + <controls:NavigationControl x:Name="navigationControl" TransitionType="Slide"> + <local:RMLExtensionsView /> + <local:RMLExtentionView/> + </controls:NavigationControl> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MainView.xaml.cs new file mode 100644 index 000000000..d5af040f6 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/MainView.xaml.cs @@ -0,0 +1,36 @@ +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; +using Tango.Core.DI; +using Tango.MachineStudio.ThreadExtensions.Contracts; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for MainView.xaml + /// </summary> + public partial class MainView : UserControl, IMainView + { + public MainView() + { + InitializeComponent(); + TangoIOC.Default.Register<IMainView>(this); + } + + public void NavigateTo(RMLExtensionNavigationView view) + { + navigationControl.NavigateTo(view.ToString()); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml new file mode 100644 index 000000000..be255f749 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml @@ -0,0 +1,107 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.RMLExtentionView" + 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:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:localconv ="clr-namespace:Tango.MachineStudio.ThreadExtensions.Converters" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"/> + <localconv:ComboBoxVisibleConverter x:Key="ComboBoxVisibleConverter"/> + + <ObjectDataProvider x:Key="RMLExtensionStatus" ObjectType="{x:Type sys:Enum}" MethodName="GetValues"> + <ObjectDataProvider.MethodParameters> + <x:Type TypeName="enumerations:RMLExtensionStatus"/> + </ObjectDataProvider.MethodParameters> + </ObjectDataProvider> + + + <ObjectDataProvider x:Key="RMLExtensionLevel" ObjectType="{x:Type sys:Enum}" MethodName="GetValues"> + <ObjectDataProvider.MethodParameters> + <x:Type TypeName="enumerations:RMLExtensionLevel"/> + </ObjectDataProvider.MethodParameters> + </ObjectDataProvider> + + </UserControl.Resources> + <Grid> + <DockPanel> + <Grid DockPanel.Dock="Top" Panel.ZIndex="200"> + <StackPanel Orientation="Horizontal"> + <Button Style="{StaticResource MaterialDesignFlatButton}" Height="Auto" Command="{Binding BackToThreadExtensionViewsCommand}"> + <materialDesign:PackIcon Kind="ArrowLeft" Width="50" Height="50" Foreground="{StaticResource DarkGrayBrush200}" ToolTip="Back to Thread list" /> + </Button> + <TextBlock MaxWidth="350" Text="{Binding ActiveRML.Name}" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="30" TextWrapping="Wrap"></TextBlock> + </StackPanel> + <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0 20 50 0"> + <TextBlock Text="Level: " VerticalAlignment="Center" FontSize="20" Margin="0 3 0 0"></TextBlock> + <ComboBox Margin="20 0 40 0" FontSize="20" ItemsSource="{Binding Source={StaticResource RMLExtensionLevel}}" SelectedItem="{Binding ActiveRMLExtension.Level, Mode=TwoWay}" Width="Auto"> + <ComboBox.ItemTemplate> + <DataTemplate> + <TextBlock Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + <TextBlock Text="Status: " VerticalAlignment="Center" FontSize="20" Margin="0 3 0 0"></TextBlock> + <ComboBox Margin="20 0 40 0" FontSize="20" ItemsSource="{Binding Source={StaticResource RMLExtensionStatus}}" SelectedItem="{Binding ActiveRMLExtension.RMLStatus, Mode=TwoWay}" Width="160"> + <ComboBox.ItemTemplate> + <DataTemplate> + <TextBlock Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </DataTemplate> + </ComboBox.ItemTemplate> + <ComboBox.ItemContainerStyle> + <Style TargetType="ComboBoxItem"> + <Style.Triggers> + <DataTrigger Binding="{Binding Path=Content, RelativeSource={RelativeSource Self},Converter={StaticResource ComboBoxVisibleConverter}}" Value="true"> + <Setter Property="Visibility" Value="Collapsed"/> + </DataTrigger> + </Style.Triggers> + </Style> + </ComboBox.ItemContainerStyle> + </ComboBox> + </StackPanel> + + </Grid> + <Grid DockPanel.Dock="Bottom"> + + </Grid> + + <Grid> + <Grid IsEnabled="{Binding IsFree}" Margin="40" > + <TabControl Background="Transparent" Margin="0,-70,0,0" x:Name="processTabControl" Padding="0 25 0 0" > + <TabControl.Resources> + <Style TargetType="TabPanel"> + <Setter Property="HorizontalAlignment" Value="Center"/> + </Style> + <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}"> + <Setter Property="Padding" Value="20,2"></Setter> + </Style> + </TabControl.Resources> + <TabItem Header="THREAD CHARACTERISTICS" Margin="-100 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:ThreadCharacteristicsView x:Name="threadParametersView" /> + </TabItem> + <TabItem Header="MACHINE TEST RESULTS" Margin="-100 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:MachineTestResultsView/> + </TabItem> + <!--<TabItem Header="COLOR PARAMETERS" Margin="-100 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:ColorParametersView/> + </TabItem> + <TabItem Header="TEST RESULTS" Margin="-100 0 0 0" mahapps:ControlsHelper.HeaderFontSize="20"> + <local:TestResultsView /> + </TabItem>--> + </TabControl> + </Grid> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml.cs new file mode 100644 index 000000000..1c7978f64 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionView.xaml.cs @@ -0,0 +1,27 @@ +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.Shapes; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for ThreadExtView.xaml + /// </summary> + public partial class RMLExtentionView : UserControl + { + public RMLExtentionView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml new file mode 100644 index 000000000..3ab0d2d24 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml @@ -0,0 +1,77 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.RMLExtensionsView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + xmlns:observables="clr-namespace:Tango.BL.Entities;assembly=Tango.BL" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:localconverters="clr-namespace:Tango.MachineStudio.ThreadExtensions.Converters" + mc:Ignorable="d" + d:DesignHeight="1080" d:DesignWidth="1920" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + <converters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter" /> + <converters:ColorToIntegerConverter x:Key="ColorToIntegerConverter"/> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"/> + <localconverters:BoolToDisplayStatusConverter x:Key="BoolToDisplayStatusConverter"/> + </UserControl.Resources> + + <Grid IsEnabled="{Binding IsFree}"> + <DockPanel Margin="100 100 100 50" MaxWidth="1200"> + <Grid DockPanel.Dock="Top"> + <Image Source="../Images/threads.png" Width="300" Margin="10" /> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0 0 10 30"> + <materialDesign:PackIcon Kind="Magnify" Width="26" Height="26"/> + <TextBox Width="300" materialDesign:HintAssist.Hint="Search by name" Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged,Delay=500}"></TextBox> + </StackPanel> + </Grid> + <Grid DockPanel.Dock="Bottom"> + <StackPanel> + <Grid> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + <Button Margin="50 0 0 0" MinWidth="200" Height="60" Command="{Binding ManageRmlExtensionCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="Pencil" Width="24" Height="24" /> + <TextBlock Margin="10 0 0 0" FontSize="18">EDIT</TextBlock> + </StackPanel> + </Button> + </StackPanel> + </Grid> + + <StackPanel Orientation="Horizontal" Margin="0 40 0 0"> + + </StackPanel> + </StackPanel> + </Grid> + <Grid> + <DataGrid Margin="0 0 0 10" BorderBrush="Silver" IsReadOnly="True" BorderThickness="1" RowHeight="60" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding RmlExtensions}" SelectedItem="{Binding SelectedRMLExtension}"> + <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> + <Setter Property="Padding" Value="4"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTextColumn Header="RML Name" Binding="{Binding Name}" Width="Auto" /> + <DataGridTextColumn Header="MANUFACTURER" Binding="{Binding Manufacturer}" Width="Auto" /> + <DataGridTextColumn Header="BRAND" Binding="{Binding Brand}" Width="Auto" /> + <DataGridTextColumn Header="LINEAR DENSITY" Binding="{Binding LinearDensity}" Width="140"/> + <DataGridTextColumn Header="CREATED BY" Binding="{Binding CreatedBy}" Width="Auto"/> + <DataGridTextColumn Header="CREATED" Binding="{Binding Created,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" /> + <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" /> + <DataGridTextColumn Header="STATUS" Binding="{Binding Status, Converter={StaticResource EnumToDescriptionConverter}}" Width="Auto" /> + <DataGridTextColumn Header="Level" Binding="{Binding Level, Converter={StaticResource EnumToDescriptionConverter}}" Width="1*" /> + </DataGrid.Columns> + </DataGrid> + </Grid> + </DockPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml.cs new file mode 100644 index 000000000..03bac4bbe --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml.cs @@ -0,0 +1,27 @@ +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.Shapes; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for ThreadExtViews.xaml + /// </summary> + public partial class RMLExtensionsView : UserControl + { + public RMLExtensionsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml new file mode 100644 index 000000000..7435112b7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml @@ -0,0 +1,646 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.TestResultsView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:local="clr-namespace:Tango.MachineStudio.ThreadExtensions.Views" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:localconverters="clr-namespace:Tango.MachineStudio.ThreadExtensions.Converters" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete" + xmlns:fa="http://schemas.fontawesome.io/icons/" + mc:Ignorable="d" + d:DesignHeight="950" d:DesignWidth="1200" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}" FontSize="16"> + + <UserControl.Resources> + + <localconverters:ColorNameToBrushConverter x:Key="ColorNameToBrushConverter"/> + <localconverters:ColorWithPercentToBrushConverter x:Key="ColorWithPercentToBrushConverter"/> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter" /> + <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" /> + + + <Style TargetType="{x:Type ListBoxItem}" x:Key="basicListBoxItem"> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"></Setter> + <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter> + <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> + <Setter Property="Padding" Value="0"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ListBoxItem}"> + <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="true"> + <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> + </Border> + <ControlTemplate.Triggers> + <Trigger Property="IsSelected" Value="true"> + <Setter Property="Background" TargetName="Bd" Value="Transparent"/> + </Trigger> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="IsSelected" Value="true"/> + <Condition Property="Selector.IsSelectionActive" Value="false"/> + </MultiTrigger.Conditions> + <Setter Property="Background" TargetName="Bd" Value="Transparent"/> + </MultiTrigger> + <Trigger Property="IsEnabled" Value="false"> + <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> + </Trigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + <DataTemplate x:Key="TabTemplate"> + <Border IsVisibleChanged="Border_IsVisibleChanged" BorderThickness="1" BorderBrush="{StaticResource GrayBrush50}" CornerRadius="5"> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Visibility" Value="Visible"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelected}" Value="False"> + <Setter Property="Visibility" Value="Hidden"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Border.Style> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + </Grid.ColumnDefinitions> + </Grid> + </Border> + </DataTemplate> + + <Style x:Key="CellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="Background" Value="Transparent"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="Focusable" Value="false"/> + <Setter Property="IsHitTestVisible" Value="false"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Top"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="HideUpDownButtons" Value="true"/> + <Setter Property="FontSize" Value="16"/> + </Style> + + <Style x:Key="EditableCellNumericUpDown" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource {x:Type mahapps:NumericUpDown}}"> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/> + <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/> + <Setter Property="FrameworkElement.VerticalAlignment" Value="Center"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="FrameworkElement.MinHeight" Value="0"/> + <Setter Property="FontSize" Value="16"/> + </Style> + <Style x:Key="EditableCellNumericUpDownWithTrigger" TargetType="{x:Type mahapps:NumericUpDown}" BasedOn="{StaticResource EditableCellNumericUpDown}"> + <Setter Property="Visibility" Value="Visible" /> + <Style.Triggers> + <DataTrigger Binding="{Binding TestResultColor, Converter={StaticResource EnumToDescriptionConverter}}" Value="REF"> + <Setter Property="Visibility" Value="Collapsed" /> + </DataTrigger> + </Style.Triggers> + </Style> + + <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> + + <Style x:Key="Rounded_Corners_TextBox_Multiline" TargetType="TextBox"> + <Setter Property="Background" Value="{StaticResource TransparentBackgroundBrush}"></Setter> + <Setter Property="BorderBrush" Value="{StaticResource DarkGrayBrush200}"></Setter> + <Setter Property="Foreground" Value="{StaticResource HomePageForeground}"></Setter> + <Setter Property="VerticalContentAlignment" Value="Top"></Setter> + <Setter Property="HorizontalContentAlignment" Value="Left"></Setter> + <Setter Property="Height" Value="Auto"></Setter> + <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/> + <Setter Property="FocusVisualStyle" Value="{x:Null}"/> + <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/> + <Setter Property="Stylus.IsFlicksEnabled" Value="False"/> + <Setter Property="AcceptsReturn" Value="True"></Setter> + <Setter Property="CaretBrush" Value="{StaticResource GrayBrush200}"></Setter> + <Setter Property="Padding" Value="3"></Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type TextBoxBase}"> + <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" CornerRadius="5"> + <ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto"/> + </Border> + <ControlTemplate.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value= "{StaticResource DimGrayBrush}"/> + </Trigger> + <Trigger Property="Width" Value="Auto"> + <Setter Property="MinWidth" Value="100"/> + </Trigger> + <Trigger Property="Height" Value="Auto"> + <Setter Property="MinHeight" Value="20"/> + </Trigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + + </UserControl.Resources> + <Grid DataContext="{Binding TestResultsViewVM}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + <DockPanel Grid.Row="0"> + <Button DockPanel.Dock="Top" HorizontalAlignment="Right" Width="170" Height="36" Margin="0 0 26 0" VerticalAlignment="Center" Command="{Binding SaveCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">SAVE</TextBlock> + </StackPanel> + </Button> + <!--<StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> + <TextBlock Margin="40 20" FontSize="30" FontWeight="SemiBold" FontStyle="Italic">TARGET MACHINE</TextBlock> + + <autoComplete:AutoCompleteTextBox Provider="{StaticResource MachinesProvider}" LoadingContent="Loading..." FontSize="20" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" materialDesign:HintAssist.Hint="Serial Number" DisplayMember="SerialNumber" Width="280"> + <autoComplete:AutoCompleteTextBox.ItemTemplate> + <DataTemplate> + <StackPanel> + <TextBlock Text="{Binding SerialNumber}" FontWeight="Bold" FontStyle="Italic"></TextBlock> + <TextBlock FontSize="11" Text="{Binding Name}" Foreground="Gray"></TextBlock> + </StackPanel> + </DataTemplate> + </autoComplete:AutoCompleteTextBox.ItemTemplate> + </autoComplete:AutoCompleteTextBox> + </StackPanel>--> + </DockPanel> + <Grid Grid.Row="1" > + <Grid.RowDefinitions> + <RowDefinition Height="30"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + + <StackPanel Orientation="Horizontal" Margin="35 0 0 0"> + <ListBox Style="{x:Null}" HorizontalAlignment="Left" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" ItemContainerStyle="{StaticResource basicListBoxItem}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="Transparent" BorderThickness="0" ItemsSource="{Binding ResultTabs}" SelectedItem="{Binding SelectedTab}"> + <ListBox.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel HorizontalAlignment="Left" Orientation="Horizontal"></StackPanel> + </ItemsPanelTemplate> + </ListBox.ItemsPanel> + + <ListBox.ItemTemplate> + <DataTemplate> + <Border Padding="5 5" Width="160" CornerRadius="10 10 0 0" Margin="1 0" Tag="{Binding RelativeSource={RelativeSource AncestorType=ListBox},Path=DataContext}"> + <Border.ContextMenu> + <ContextMenu DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}" Style="{x:Null}" > + <MenuItem Header="Rename" Command="{Binding RenameTabCommand}" MinWidth="210" MaxHeight="40" > + <MenuItem.Icon> + <fa:ImageAwesome Icon="Pencil" Width="16" /> + </MenuItem.Icon> + </MenuItem> + </ContextMenu> + </Border.ContextMenu> + <Border.Style> + <Style TargetType="Border"> + <Setter Property="Background" Value="{StaticResource LightGrayBrush150}"></Setter> + <Setter Property="TextElement.Foreground" Value="{StaticResource DarkGrayBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter> + <Setter Property="TextElement.Foreground" Value="{StaticResource WhiteTextBrush}"></Setter> + </DataTrigger> + <Trigger Property="IsMouseOver" Value="True"> + <Setter Property="Opacity" Value="0.8"></Setter> + </Trigger> + </Style.Triggers> + </Style> + </Border.Style> + <DockPanel VerticalAlignment="Center"> + <Button Cursor="Hand" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}, Path=DataContext.RemoveTabCommand}" CommandParameter="{Binding }" DockPanel.Dock="Right" Margin="5 0 0 0" Style="{StaticResource MaterialDesignFlatButton}" Padding="2" Height="Auto"> + <materialDesign:PackIcon Kind="Close"> + <materialDesign:PackIcon.Style> + <Style TargetType="materialDesign:PackIcon"> + <Setter Property="Foreground" Value="{StaticResource DarkGrayBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding IsSelected}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource WhiteTextBrush}"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </materialDesign:PackIcon.Style> + </materialDesign:PackIcon> + </Button> + <TextBlock Text="{Binding TestResult.Name}" VerticalAlignment="Center" TextAlignment="Center" TextTrimming="CharacterEllipsis" FontSize="11"></TextBlock> + </DockPanel> + </Border> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + <Button Margin="10 0 0 0" Style="{StaticResource MaterialDesignFlatButton}" Padding="2" Height="24" Cursor="Hand" Command="{Binding AddTabCommand}" ToolTip="New tab"> + <materialDesign:PackIcon Width="20" Height="20" Kind="Plus" Foreground="{StaticResource AccentColorBrush}" /> + </Button> + </StackPanel> + <Grid Margin="5 0 5 5" Grid.Row="1"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"/> + <ColumnDefinition Width="20"/> + </Grid.ColumnDefinitions> + + <ItemsControl ItemsSource="{Binding ResultTabs}" ItemTemplate="{StaticResource TabTemplate}"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <Grid/> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + </ItemsControl> + + <Grid Grid.Column="0" MinWidth="600" HorizontalAlignment="Left" > + <DockPanel > + + <Button DockPanel.Dock="Bottom" Width="200" HorizontalAlignment="Right" Margin="20" Command="{Binding SelectedTab.ExportToFileCommand}" IsEnabled="False"> Export to File</Button> + + <Grid DockPanel.Dock="Bottom" Margin="20 10 20 0"> + <TextBlock FontSize="21">Conclusion:</TextBlock> + <TextBox Margin="120 0 10 0" HorizontalAlignment="Stretch" MinHeight="40" Text="{Binding SelectedTab.TestResult.Conclusions}" Style="{StaticResource Rounded_Corners_TextBox_Multiline}"></TextBox> + </Grid> + + <Grid DockPanel.Dock="Bottom" Margin="20 10 20 0"> + <TextBlock FontSize="21">Comments:</TextBlock> + <TextBox Margin="120 0 10 0" Style="{StaticResource Rounded_Corners_TextBox_Multiline}" HorizontalAlignment="Stretch" MinHeight="40" Text="{Binding SelectedTab.TestResult.Comment}"></TextBox> + + </Grid> + + <Border Padding="10 10 20 10" DockPanel.Dock="Top" BorderBrush="Transparent" BorderThickness="1" > + + <ScrollViewer VerticalScrollBarVisibility="Auto" > + <Grid HorizontalAlignment="Left"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="1*"></ColumnDefinition> + <ColumnDefinition Width="1*"></ColumnDefinition> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="1*"/> + </Grid.RowDefinitions> + <Border> + <StackPanel x:Name="DryerTempPanel" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="0" > + <DockPanel Margin="0 0 0 0"> + <Button DockPanel.Dock="Right" Margin="0 0 40 0" HorizontalAlignment="Left" Padding="0" Height="Auto" Width="200" Command="{Binding ApplyToProcessParametersCommand}" ToolTip="Apply to Process Parameters" VerticalContentAlignment="Center"> + <TextBlock FontSize="14" Background="Transparent" VerticalAlignment="Center" Margin="0 2 0 0">Apply to Process Parameters</TextBlock> + </Button> + <TextBlock HorizontalAlignment="Center" FontSize="21" Margin="180 10 0 0"> Process Parameters</TextBlock> + </DockPanel> + <Border BorderThickness="1" BorderBrush="{StaticResource GrayBrush200}" Margin="20 10 40 10"> + <UniformGrid Columns="2" HorizontalAlignment="Left" MinWidth="{ Binding ElementName=RubbingResultsGrid, Path= ActualWidth }" > + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Dryer temperature</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown HasDecimals="False" HorizontalContentAlignment="Left" Minimum="0" Maximum="300" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" Value="{Binding SelectedTab.TestResult.DryerTemperature, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Margin="10 0 0 0"></mahapps:NumericUpDown> + </Border> + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Tunnel temperature</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="False" Minimum="0" Maximum="400" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TunnelTemperature,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Margin="10 0 0 0"></mahapps:NumericUpDown> + </Border> + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Tunnel flow</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="20" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TunnelFlow,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Margin="10 0 0 0"></mahapps:NumericUpDown> + </Border> + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Tunnel AVG temperature</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="400" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TunnelAvgTemperature,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Margin="10 0 0 0"></mahapps:NumericUpDown> + </Border> + </UniformGrid> + </Border> + </StackPanel></Border> + <StackPanel x:Name="RubbingResultsPanel" Grid.Column="0" Grid.Row="1" Margin="0 5 0 0"> + <TextBlock HorizontalAlignment="Center" FontSize="21"> Rubbing results</TextBlock> + + <DataGrid x:Name="RubbingResultsGrid" HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="280" RowHeight="26" Padding="0" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding SelectedTab.TestResult.RubbingResults}" Margin="20 10 40 10" FontSize="16"> + <DataGrid.ColumnHeaderStyle > + <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}"> + <Setter Property="FontSize" Value="16"/> + <Setter Property="HorizontalAlignment" Value="Left"/> + <Setter Property="Margin" Value="2 0 0 0"/> + <Setter Property="Padding" Value="0 5"/> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + </Style> + </DataGrid.ColumnHeaderStyle> + <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> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTemplateColumn Header="Color" Width="80"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Border BorderThickness="0" Background="{Binding TestResultColor, Converter={StaticResource ColorNameToBrushConverter}}"> + <TextBlock Text="{Binding TestResultColor, Converter={StaticResource EnumToDescriptionConverter}}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0"></TextBlock> + </Border> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + + <mahapps:DataGridNumericUpDownColumn Header="DeltaE CIE 100%" Minimum="0" Maximum="100" Binding="{Binding DeltaeCie100, StringFormat={}{0:F2}}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" /> + + + <DataGridTemplateColumn Header="GS 100%" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="1" Maximum="5" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding Gs100Min,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> -</TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="1" Maximum="5" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding Gs100Max,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + + <mahapps:DataGridNumericUpDownColumn Header="DeltaE CIE 200%" Minimum="0" Maximum="100" Binding="{Binding DeltaeCie200}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" FontSize="16"/> + + <DataGridTemplateColumn Header="GS 200%" Width="1*"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="1" Maximum="5" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding Gs200Min,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> -</TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="1" Maximum="5" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding Gs200Max,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + </DataGrid.Columns> + </DataGrid> + + </StackPanel> + <StackPanel x:Name="TensionresultsPanel" Grid.Column="1" Grid.Row="0" Margin="0 10 0 0" > + <TextBlock HorizontalAlignment="Center" FontSize="21"> Tension through the thread path</TextBlock> + <Border BorderThickness="1" BorderBrush="{StaticResource GrayBrush200}" Margin="0 10 20 10" > + <UniformGrid Columns="4" Background="{StaticResource TransparentBackgroundBrush}" HorizontalAlignment="Left" MinWidth="{ Binding ElementName=MechanicalPropertiesGrid, Path= ActualWidth }" > + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" Margin="5 0 0 0" VerticalAlignment="Center">Tension in Zone</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" Margin="5 0 0 0" VerticalAlignment="Center">Tensiometer (gr)</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" Margin="5 0 0 0" VerticalAlignment="Center">Tension in Zone</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" Margin="5 0 0 0" VerticalAlignment="Center">MS</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0">Head</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TensionHeadMin,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="10 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> -</TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TensionHeadMax,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0">BTSR</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.BtsrMin,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="10 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> -</TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.BtsrMax,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0">After dryer</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TensionAfterDryerMin,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="10 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> -</TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TensioinAfterDryerMax,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0" >Puller tension</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.PullerTensionMin,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="10 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> -</TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.PullerTensionMax,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0">Winder</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TensionWinderMin,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="10 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> -</TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.TensionWinderMax,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0">Winder Exit Tension</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.ExitTensionMin,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="10 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Right" MinWidth="26"/> + <TextBlock FontSize="16" VerticalAlignment="Center"> - </TextBlock> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.ExitTensionMax,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 0" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" MinWidth="26"/> + </StackPanel> + </Border> + </UniformGrid> + </Border> + </StackPanel> + <StackPanel x:Name="MechanicalPropertiesPanel" Grid.Column="1" Grid.Row="1" Margin="0 5 0 0"> + <TextBlock HorizontalAlignment="Center" FontSize="21" >Mechanical properties</TextBlock> + <DataGrid x:Name="MechanicalPropertiesGrid" HorizontalAlignment="Left" VerticalScrollBarVisibility ="Auto" MaxHeight="250" RowHeight="26" Padding="0" SelectionUnit="FullRow" BorderBrush="{StaticResource DarkGrayBrush }" BorderThickness="1" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding SelectedTab.TestResult.TensileResults}" Margin="0 10 20 10" FontSize="16"> + <DataGrid.ColumnHeaderStyle > + <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}"> + <Setter Property="FontSize" Value="16"/> + <Setter Property="HorizontalAlignment" Value="Left"/> + <Setter Property="Margin" Value="2 0 0 0"/> + <Setter Property="Padding" Value="0 5"/> + <Setter Property="FrameworkElement.HorizontalAlignment" Value="Stretch"/> + <Setter Property="HorizontalContentAlignment" Value="Left"/> + </Style> + </DataGrid.ColumnHeaderStyle> + <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> + <Setter Property="Padding" Value="0"></Setter> + <Setter Property="Margin" Value="0 0 0 0"></Setter> + </Style> + </DataGrid.CellStyle> + <DataGrid.Columns> + <DataGridTextColumn Header="% Color" Binding="{ Binding ColorPercent}" MinWidth="100"></DataGridTextColumn> + <DataGridTemplateColumn Header="Color" Width="80"> + <DataGridTemplateColumn.CellTemplate> + <DataTemplate> + <Border BorderThickness="0"> + <Border.Background> + <MultiBinding Converter="{StaticResource ColorWithPercentToBrushConverter}"> + <Binding Path="TestResultColor"></Binding> + <Binding Path="ColorPercent"></Binding> + </MultiBinding> + </Border.Background> + <TextBlock Text="{Binding TestResultColor, Converter={StaticResource EnumToDescriptionConverter}}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10 0 0 0"></TextBlock> + </Border> + </DataTemplate> + </DataGridTemplateColumn.CellTemplate> + </DataGridTemplateColumn> + + <mahapps:DataGridNumericUpDownColumn Header="Load at 
Maximum 
Load(N)" Minimum="0" Maximum="100" Binding="{Binding MaxLoad}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" StringFormat="{}{0:F2}" /> + <mahapps:DataGridNumericUpDownColumn Header="STDEV" Minimum="0" Maximum="100" Binding="{Binding StdevMaxLoad}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" StringFormat="{}{0:F2}" /> + <mahapps:DataGridNumericUpDownColumn Header="% Change" Minimum="-100" Maximum="100" Binding="{Binding PercentChangeLoad}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDownWithTrigger}" StringFormat="{}{0:F2}" > + <mahapps:DataGridNumericUpDownColumn.CellStyle> + <Style TargetType="DataGridCell"> + <Setter Property="Visibility" Value="Visible"/> + <Style.Triggers> + <DataTrigger Binding="{ Binding IsWhiteColor}" Value="True"> + <Setter Property="Visibility" Value="Hidden"/> + </DataTrigger> + </Style.Triggers> + </Style> + </mahapps:DataGridNumericUpDownColumn.CellStyle> + </mahapps:DataGridNumericUpDownColumn> + + <mahapps:DataGridNumericUpDownColumn Header="Percentage 
Strain at 
Maximum Load" Minimum="0" Maximum="100" Binding="{Binding StrainMaxLoad}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" StringFormat="{}{0:F2}" > + + </mahapps:DataGridNumericUpDownColumn> + + <mahapps:DataGridNumericUpDownColumn Header="STDEV" Minimum="0" Maximum="100" Binding="{Binding StdevStrainMaxLoad}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDown}" StringFormat="{}{0:F2}" /> + + <mahapps:DataGridNumericUpDownColumn Header="% Change" Minimum="-100" Maximum="100" Binding="{Binding PercentChangeStrain}" HideUpDownButtons="True" Width="1*" ElementStyle="{StaticResource CellNumericUpDown}" EditingElementStyle="{StaticResource EditableCellNumericUpDownWithTrigger}" StringFormat="{}{0:F2}"> + <mahapps:DataGridNumericUpDownColumn.CellStyle> + <Style TargetType="DataGridCell"> + <Setter Property="Visibility" Value="Visible"/> + <Style.Triggers> + <DataTrigger Binding="{ Binding IsWhiteColor}" Value="True"> + <Setter Property="Visibility" Value="Hidden"/> + </DataTrigger> + </Style.Triggers> + </Style> + </mahapps:DataGridNumericUpDownColumn.CellStyle> + </mahapps:DataGridNumericUpDownColumn> + + </DataGrid.Columns> + </DataGrid> + + </StackPanel> + <StackPanel x:Name="UniformityPanel" HorizontalAlignment="Center" Grid.Column="0" Grid.Row="2" > + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0" FontSize="21"> Uniformity</TextBlock> + <Border BorderThickness="1" BorderBrush="{StaticResource GrayBrush200}" Margin="20 10 40 10"> + <UniformGrid Columns="2" HorizontalAlignment="Left" MinWidth="{ Binding ElementName=RubbingResultsGrid, Path= ActualWidth }" > + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" Margin="5 0 0 0" VerticalAlignment="Center">Uniformity</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" VerticalAlignment="Center" Margin="5 0 0 0">Severity</TextBlock> + </Border> + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}" > + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Zone 1</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="10" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Right" Value="{Binding SelectedTab.TestResult.SeverityZone1Min,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10 0 0 0" Padding="0" StringFormat="{}{0:F1}" HorizontalAlignment="Right" FontSize="16" MinWidth="26"></mahapps:NumericUpDown> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">-</TextBlock> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="10" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.SeverityZone1Max,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0 0 0 0" Width="Auto" FontSize="16" StringFormat="{}{0:F1}" ></mahapps:NumericUpDown> + </StackPanel> + </Border> + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">Zone 2</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="10" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Right" Value="{Binding SelectedTab.TestResult.SeverityZone2Min,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10 0 0 0" MaxWidth="20" Padding="0" StringFormat="{}{0:F1}" HorizontalAlignment="Right" FontSize="16" MinWidth="26"></mahapps:NumericUpDown> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">-</TextBlock> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="10" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Left" Value="{Binding SelectedTab.TestResult.SeverityZone2Max,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0 0 0 0" Width="Auto" FontSize="16" StringFormat="{}{0:F1}" ></mahapps:NumericUpDown> + </StackPanel> + </Border> + </UniformGrid> + </Border> + </StackPanel> + <StackPanel x:Name="COFPanel" HorizontalAlignment="Center" Grid.Column="1" Grid.Row="2" > + <TextBlock HorizontalAlignment="Center" Margin="0 5 0 0" FontSize="21"> COF</TextBlock> + <Border BorderThickness="1" BorderBrush="{StaticResource GrayBrush200}" Margin="0 10 20 10" > + <UniformGrid Columns="4" HorizontalAlignment="Left" MinWidth="{ Binding ElementName=MechanicalPropertiesGrid, Path= ActualWidth }" > + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" Margin="5 0 0 0" VerticalAlignment="Center">Thread name</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" VerticalAlignment="Center" Margin="5 0 0 0">Lub version</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" VerticalAlignment="Center" Margin="5 0 0 0">COF</TextBlock> + </Border> + <Border BorderThickness="0 1 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock FontWeight="Light" VerticalAlignment="Center" Margin="5 0 0 0">Lub amount</TextBlock> + </Border> + + + <Border BorderThickness="1 0 1 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}" > + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center">REF</TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBox Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding SelectedTab.TestResult.RefLubVersion}"></TextBox> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="10" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Right" Value="{Binding SelectedTab.TestResult.RefCof,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10 0 0 0" MaxWidth="20" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" FontSize="16"></mahapps:NumericUpDown> + </Border> + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush700}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Right" Value="{Binding SelectedTab.TestResult.RefLub,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10 0 0 0" MaxWidth="20" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" FontSize="16"></mahapps:NumericUpDown> + </Border> + + + <Border BorderThickness="1 0 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding ThreadName}"></TextBlock> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <TextBox Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding SelectedTab.TestResult.ThreadLubVersion}"></TextBox> + </Border> + <Border BorderThickness="0 0 0 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="10" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Right" Value="{Binding SelectedTab.TestResult.ThreadCof,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10 0 0 0" MaxWidth="20" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" FontSize="16"></mahapps:NumericUpDown> + </Border> + <Border BorderThickness="0 0 1 1" Background="{StaticResource TransparentBackgroundBrush}" BorderBrush="{StaticResource BorderBrushGainsboro}"> + <mahapps:NumericUpDown VerticalAlignment="Center" HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" HideUpDownButtons="True" InterceptMouseWheel="True" HorizontalContentAlignment="Right" Value="{Binding SelectedTab.TestResult.ThreadLub,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10 0 0 0" MaxWidth="20" Padding="0" StringFormat="{}{0:F2}" HorizontalAlignment="Left" FontSize="16"></mahapps:NumericUpDown> + </Border> + </UniformGrid> + </Border> + </StackPanel> + </Grid> + </ScrollViewer> + </Border> + + </DockPanel> + </Grid> + </Grid> + </Grid> + + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml.cs new file mode 100644 index 000000000..a75dc5d09 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/TestResultsView.xaml.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +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; +using Tango.MachineStudio.ThreadExtensions.ViewModels; + +namespace Tango.MachineStudio.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for TestResultsView.xaml + /// </summary> + public partial class TestResultsView : UserControl + { + private Dictionary<Border, UIElement> _tabs_content; + + public TestResultsView() + { + InitializeComponent(); + + _tabs_content = new Dictionary<Border, UIElement>(); + + this.Loaded += TestResultsView_Loaded; + } + private void TestResultsView_Loaded(object sender, RoutedEventArgs e) + { + + } + private void Border_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + Border border = sender as Border; + if (border.Visibility != Visibility.Visible) + { + _tabs_content[border] = border.Child; + border.Child = null; + } + else + { + if (_tabs_content.ContainsKey(border)) + { + border.Child = _tabs_content[border]; + } + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml new file mode 100644 index 000000000..caab8edfb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml @@ -0,0 +1,237 @@ +<UserControl x:Class="Tango.MachineStudio.ThreadExtensions.Views.ThreadCharacteristicsView" + 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.ThreadExtensions.Views" + xmlns:vm="clr-namespace:Tango.MachineStudio.ThreadExtensions.ViewModels" + xmlns:global="clr-namespace:Tango.MachineStudio.ThreadExtensions" + xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + mc:Ignorable="d" + FontSize="16" + d:DesignHeight="850" d:DesignWidth="1200" Background="Transparent" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + <UserControl.Resources> + <converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"/> + + <ObjectDataProvider x:Key="TwistDirections" ObjectType="{x:Type sys:Enum}" MethodName="GetValues"> + <ObjectDataProvider.MethodParameters> + <x:Type TypeName="enumerations:TwistDirections"/> + </ObjectDataProvider.MethodParameters> + </ObjectDataProvider> + + <ObjectDataProvider x:Key="Plies" ObjectType="{x:Type sys:Enum}" MethodName="GetValues"> + <ObjectDataProvider.MethodParameters> + <x:Type TypeName="enumerations:Plies"/> + </ObjectDataProvider.MethodParameters> + </ObjectDataProvider> + + </UserControl.Resources> + + <Grid> + <materialDesign:Card Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch" Padding="40"> + <Grid> + <Grid.RowDefinitions> + <RowDefinition Height="1*"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <UniformGrid Columns="4" Grid.Row="0"> + + <Grid Margin="10"> + <materialDesign:Card Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch" > + <Grid Margin="20"> + <DockPanel> + <TextBlock DockPanel.Dock="Top" Margin="20 10 0 10" FontSize="20" FontWeight="DemiBold">Yarn Source</TextBlock> + <controls:TableGrid RowHeight="60" Margin="0 20 0 0" MakeFirstColumnVerticalAlignmentBottom="False" > + <controls:TableGrid.Resources> + <Style TargetType="TextBlock"> + <Setter Property="VerticalAlignment" Value="Center"></Setter> + <Setter Property="Margin" Value="0 3 0 0"></Setter> + </Style> + </controls:TableGrid.Resources> + <TextBlock Text="Manufacturer:" VerticalAlignment="Center" FontSize="16" Margin="0 3 0 0"></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Manufacturers}" SelectedItem="{Binding ActiveRML.Manufacturer,Mode=TwoWay}" AddCommand="{Binding AddManufacturerItemCommand}" EditCommand="{Binding EditManufacturerItemCommand}"/> + + <TextBlock Text="Brand:" VerticalAlignment="Center" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Brands}" SelectedItem="{Binding ActiveRMLExtension.YarnBrand,Mode=TwoWay}" DisplayMemberPath="Name" AddCommand="{Binding AddBrandItemCommand}" EditCommand="{Binding EditBrandItemCommand}"/> + + <TextBlock Text="Country:" ></TextBlock> + <TextBox Text="{Binding ActiveRMLExtension.Country,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"></TextBox> + + <TextBlock Text="End Use:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding EndUse}" SelectedItem="{Binding ActiveRML.MediaPurpose,Mode=TwoWay}" DisplayMemberPath="Name" AddCommand="{Binding AddEndUseItemCommand}" EditCommand="{Binding EditEndUseItemCommand}"/> + + <TextBlock Text="Applications:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Applications}" SelectedItem="{Binding ActiveRMLExtension.YarnApplication,Mode=TwoWay}" DisplayMemberPath="Name" AddCommand="{Binding AddApplicationItemCommand}" EditCommand="{Binding EditApplicationItemCommand}"/> + + <TextBlock Text="Industry Sector:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding IndustrySector}" SelectedItem="{Binding ActiveRMLExtension.YarnIndustrysector}" DisplayMemberPath="Name" AddCommand="{Binding AddIndustrySectorItemCommand}" EditCommand="{Binding EditIndustrySectorItemCommand}"/> + + </controls:TableGrid> + </DockPanel> + </Grid> + </materialDesign:Card> + </Grid> + + <Grid Margin="10"> + <materialDesign:Card Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch" > + <Grid Margin="20"> + <DockPanel> + <TextBlock DockPanel.Dock="Top" FontSize="20" FontWeight="DemiBold">Yarn Source</TextBlock> + <controls:TableGrid RowHeight="55" Margin="0 20 0 0" MakeFirstColumnVerticalAlignmentBottom="False" > + <controls:TableGrid.Resources> + <Style TargetType="TextBlock"> + <Setter Property="VerticalAlignment" Value="Center"></Setter> + <Setter Property="Margin" Value="0 3 0 0"></Setter> + </Style> + </controls:TableGrid.Resources> + <TextBlock Text="Material:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Materials}" SelectedItem="{Binding ActiveRML.MediaMaterial}" DisplayMemberPath="Name" AddCommand="{Binding AddMaterialItemCommand}" EditCommand="{Binding EditMaterialItemCommand}"/> + + <TextBlock Text="Type:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding YarnTypes}" SelectedItem="{Binding ActiveRMLExtension.YarnType}" DisplayMemberPath="Name" AddCommand="{Binding AddYarnTypeItemCommand}" EditCommand="{Binding EditYarnTypeItemCommand}"/> + + <TextBlock Text="Sub family:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding SubFamilies}" SelectedItem="{Binding ActiveRMLExtension.YarnSubFamily}" DisplayMemberPath="Name" AddCommand="{Binding AddSubFamilyItemCommand}" EditCommand="{Binding EditSubFamilyItemCommand}"/> + + <TextBlock Text="Family:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Family}" SelectedItem="{Binding ActiveRMLExtension.YarnFamily}" DisplayMemberPath="Name" AddCommand="{Binding AddFamilyItemCommand}" EditCommand="{Binding EditFamilyItemCommand}"/> + + <TextBlock Text="Group:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Group}" SelectedItem="{Binding ActiveRMLExtension.YarnGroup}" DisplayMemberPath="Name" AddCommand="{Binding AddGroupItemCommand}" EditCommand="{Binding EditGroupItemCommand}"/> + + <TextBlock Text="Texturing:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Texturing}" SelectedItem="{Binding ActiveRMLExtension.YarnTexturing}" DisplayMemberPath="Name" AddCommand="{Binding AddTexturingItemCommand}" EditCommand="{Binding EditTexturingItemCommand}"/> + + <TextBlock Text="Geometry:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding Geometry}" SelectedItem="{Binding ActiveRML.FiberShape}" DisplayMemberPath="Name" AddCommand="{Binding AddGeometryItemCommand}" EditCommand="{Binding EditGeometryItemCommand}"/> + + <TextBlock Text="Thread Shade:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding YarnWhiteShade}" SelectedItem="{Binding ActiveRMLExtension.YarnWhiteShade}" DisplayMemberPath="Name" AddCommand="{Binding AddYarnWhiteShadeItemCommand}" EditCommand="{Binding EditYarnWhiteShadeItemCommand}"/> + + <TextBlock Text="Gloss level:" ></TextBlock> + <local:ComboboxEditable ItemsSource="{Binding GlossLevel}" SelectedItem="{Binding ActiveRMLExtension.YarnGlossLevel}" DisplayMemberPath="Name" AddCommand="{Binding AddGlossLevelItemCommand}" EditCommand="{Binding EditGlossLevelItemCommand}"/> + + </controls:TableGrid> + </DockPanel> + </Grid> + </materialDesign:Card> + </Grid> + <Grid Margin="10"> + <materialDesign:Card Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch" > + <Grid Margin="20"> + <DockPanel> + <TextBlock DockPanel.Dock="Top" FontSize="20" FontWeight="DemiBold">Yarn Data</TextBlock> + <controls:TableGrid RowHeight="55" Margin="0 20 0 0" MakeFirstColumnVerticalAlignmentBottom="False" > + <controls:TableGrid.Resources> + <Style TargetType="TextBlock"> + <Setter Property="VerticalAlignment" Value="Center"></Setter> + <Setter Property="Margin" Value="0 3 0 0"></Setter> + </Style> + </controls:TableGrid.Resources> + + <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="Unit:" ></TextBlock> + <ComboBox ItemsSource="{Binding Units}" SelectedItem="{Binding ActiveRML.LinearMassDensityUnit}" 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="Filament count per plies:" ></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="500" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRML.PliesPerFiber,Mode=TwoWay}" FontSize="16"></mahapps:NumericUpDown> + + <TextBlock Text="Count (den)" ></TextBlock> + <TextBlock Text="{Binding ActiveRML.DencityCount}" Foreground="Blue" ></TextBlock> + + <TextBlock Text="Fiber count " ></TextBlock> + <TextBlock Text="{Binding ActiveRML.FiberCount}" Foreground="Blue" ></TextBlock> + + <TextBlock Text="Twist(tpm):" ></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="9999" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding ActiveRMLExtension.TwistTpm,Mode=TwoWay}" FontSize="16"></mahapps:NumericUpDown> + + <TextBlock Text="Twist direction:" ></TextBlock> + <ComboBox ItemsSource="{Binding Source={StaticResource TwistDirections}}" SelectedItem="{Binding ActiveRMLExtension.YarnTwistDirections,Mode=TwoWay}" > + <ComboBox.ItemContainerStyle> + <Style TargetType="ComboBoxItem" BasedOn="{StaticResource {x:Type ComboBoxItem}}"> + <Setter Property="Background" Value="{StaticResource WhiteBrush100}"></Setter> + </Style> + </ComboBox.ItemContainerStyle> + <ComboBox.ItemTemplate> + <DataTemplate> + <TextBlock Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}"></TextBlock> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> + </controls:TableGrid> + </DockPanel> + </Grid> + </materialDesign:Card> + </Grid> + <Grid Margin="10"> + <materialDesign:Card Background="{DynamicResource MaterialDesignBackground}" VerticalAlignment="Stretch" > + <Grid Margin="20"> + <DockPanel> + <TextBlock DockPanel.Dock="Top" FontSize="20" FontWeight="DemiBold">Yarn Properties from datasheet</TextBlock> + <controls:TableGrid RowHeight="55" Margin="0 20 0 0" MakeFirstColumnVerticalAlignmentBottom="False" > + <controls:TableGrid.Resources> + <Style TargetType="TextBlock"> + <Setter Property="VerticalAlignment" Value="Center"></Setter> + <Setter Property="Margin" Value="0 3 0 0"></Setter> + </Style> + <Style TargetType="{x:Type mahapps:NumericUpDown}"> + <Setter Property="BorderThickness" Value="0 0 0 0.5"></Setter> + <Setter Property="FontSize" Value="16"/> + </Style> + </controls:TableGrid.Resources> + <TextBlock Text="Max Force (N):" ></TextBlock> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" HideUpDownButtons="True" Value="{Binding ActiveRMLExtension.MinMaxForceN}" HorizontalContentAlignment="Left" BorderBrush="{StaticResource MainWindow.Foreground}" Foreground="{StaticResource MainWindow.Foreground}" /> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" HideUpDownButtons="True" Value="{Binding ActiveRMLExtension.MaxMaxForceN}" HorizontalContentAlignment="Left" BorderBrush="{StaticResource MainWindow.Foreground}" Foreground="{StaticResource MainWindow.Foreground}" Margin="10 0 0 0"/> + </StackPanel> + + <TextBlock Text="Elasticity (%)" ></TextBlock> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" HideUpDownButtons="True" Value="{Binding ActiveRMLExtension.MinElasticity}" HorizontalContentAlignment="Left" BorderBrush="{StaticResource MainWindow.Foreground}" Foreground="{StaticResource MainWindow.Foreground}" /> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" HideUpDownButtons="True" Value="{Binding ActiveRMLExtension.MaxElasticity}" HorizontalContentAlignment="Left" BorderBrush="{StaticResource MainWindow.Foreground}" Foreground="{StaticResource MainWindow.Foreground}" Margin="10 0 0 0"/> + </StackPanel> + + <TextBlock Text="Tenacity (%)" ></TextBlock> + <StackPanel Orientation="Horizontal"> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" HideUpDownButtons="True" Value="{Binding ActiveRMLExtension.MinTenacity}" HorizontalContentAlignment="Left" BorderBrush="{StaticResource MainWindow.Foreground}" Foreground="{StaticResource MainWindow.Foreground}" /> + <mahapps:NumericUpDown HasDecimals="True" Minimum="0" Maximum="100" InterceptArrowKeys="True" HideUpDownButtons="True" Value="{Binding ActiveRMLExtension.MaxTenacity}" HorizontalContentAlignment="Left" BorderBrush="{StaticResource MainWindow.Foreground}" Foreground="{StaticResource MainWindow.Foreground}" Margin="10 0 0 0"/> + </StackPanel> + + <TextBlock Text="Finishing:" VerticalAlignment="Bottom" Margin=" 0 20 0 0"></TextBlock> + <TextBox Text="{Binding ActiveRMLExtension.Finishing}" ></TextBox> + + </controls:TableGrid> + </DockPanel> + </Grid> + </materialDesign:Card> + </Grid> + + </UniformGrid> + <Button Grid.Row="1" HorizontalAlignment="Right" Width="170" Height="45" Margin="0 0 20 0" VerticalAlignment="Center" Command="{Binding SaveCommand}"> + <StackPanel Orientation="Horizontal"> + <materialDesign:PackIcon Kind="ContentSaveAll" Width="24" Height="24" /> + <TextBlock VerticalAlignment="Center" Margin="10 0 0 0">SAVE</TextBlock> + </StackPanel> + </Button> + </Grid> + </materialDesign:Card> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.xaml.cs new file mode 100644 index 000000000..944cf07f4 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/ThreadCharacteristicsView.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.ThreadExtensions.Views +{ + /// <summary> + /// Interaction logic for ThreadCharacteristicsView.xaml + /// </summary> + public partial class ThreadCharacteristicsView : UserControl + { + public ThreadCharacteristicsView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/app.config new file mode 100644 index 000000000..7b82e5f7c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/app.config @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> + </configSections> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.6.4.0" newVersion="5.6.4.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.4.2.0" newVersion="1.4.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> + </dependentAssembly> + </assemblyBinding> + </runtime> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> + </providers> + </entityFramework> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config new file mode 100644 index 000000000..da5ed8abc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/packages.config @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> + <package id="FontAwesome.WPF" version="4.7.0.9" targetFramework="net461" /> + <package id="Google.Protobuf" version="3.4.1" targetFramework="net461" /> + <package id="MahApps.Metro" version="1.5.0" targetFramework="net461" /> + <package id="MaterialDesignColors" version="1.1.2" targetFramework="net461" /> + <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net461" /> + <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" /> + <package id="OxyPlot.Core" version="2.0.0" targetFramework="net461" /> + <package id="OxyPlot.Wpf" version="2.0.0" targetFramework="net461" /> +</packages>
\ No newline at end of file |
