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/Converters | |
| 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/Converters')
4 files changed, 170 insertions, 0 deletions
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(); + } + } +} |
