diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-12 10:35:46 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-12 10:35:46 +0300 |
| commit | 70fe7f13b519df86420f8c2b97cf8eb3ab67e9a5 (patch) | |
| tree | ab185b79e6b5f05b0a2cea46dc32b0bcdce00c02 /Software/Visual_Studio/Tango.SharedUI/Converters | |
| parent | b09df90c46d7b6411b253e09678bc4282b56f5eb (diff) | |
| download | Tango-70fe7f13b519df86420f8c2b97cf8eb3ab67e9a5.tar.gz Tango-70fe7f13b519df86420f8c2b97cf8eb3ab67e9a5.zip | |
Implemented friendly time display for job progress PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Converters')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToLabelConverter.cs | 36 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs | 36 |
2 files changed, 72 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToLabelConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToLabelConverter.cs new file mode 100644 index 000000000..167fd4bf8 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToLabelConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.SharedUI.Converters +{ + public class TimeSpanToLabelConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + TimeSpan time = (TimeSpan)value; + + if (time.TotalHours > 1) + { + return "hrs"; + } + else if (time.TotalMinutes > 1) + { + return "min"; + } + else + { + return "sec"; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs new file mode 100644 index 000000000..59b102616 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/TimeSpanToTwoDigitsTimeConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace Tango.SharedUI.Converters +{ + public class TimeSpanToTwoDigitsTimeConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + TimeSpan time = (TimeSpan)value; + + if (time.TotalHours > 1) + { + return (int)time.TotalHours; + } + else if (time.TotalMinutes > 1) + { + return (int)time.TotalMinutes; + } + else + { + return (int)time.TotalSeconds; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} |
