diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-07 20:10:55 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-12-07 20:10:55 +0200 |
| commit | a6e6af346bf160b4a83163a6f1b268920cf2005c (patch) | |
| tree | 5ac37a4c97cc4d6a65bc0c589ceea74519094f34 /Software/Visual_Studio/Tango.SharedUI | |
| parent | 40622a28006ffd38ce5b85ac49502804d65b9357 (diff) | |
| download | Tango-a6e6af346bf160b4a83163a6f1b268920cf2005c.tar.gz Tango-a6e6af346bf160b4a83163a6f1b268920cf2005c.zip | |
Implemented machine updates history on machine designer.
Related Work Items: #1618
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI')
3 files changed, 59 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs index f5b4dea87..7e534d7f0 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/StringEllipsisConverter.cs @@ -14,7 +14,14 @@ namespace Tango.SharedUI.Converters { try { - return value.ToString().Ellipsis(System.Convert.ToInt32(parameter)); + if (value != null) + { + return value.ToString().Ellipsis(System.Convert.ToInt32(parameter)); + } + else + { + return value; + } } catch { diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs new file mode 100644 index 000000000..d130ebaaf --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs @@ -0,0 +1,50 @@ +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 StringToOneLineConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + string str = value.ToString(); + int newLineIndex = str.IndexOf(Environment.NewLine); + + if (newLineIndex == -1) + { + newLineIndex = str.IndexOf("\n"); + } + + string firstline = str; + + if (newLineIndex > 0) + { + firstline = str.Substring(0, newLineIndex); + } + + if (parameter != null) + { + firstline = firstline.Ellipsis(System.Convert.ToInt32(parameter)); + } + + return firstline; + } + else + { + return value; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index a65ac7322..3429bcb59 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -130,6 +130,7 @@ <Compile Include="Converters\StringFormatConverter.cs" /> <Compile Include="Converters\StringNullOrEmptyToBooleanConverter.cs" /> <Compile Include="Converters\StringToLinesConverter.cs" /> + <Compile Include="Converters\StringToOneLineConverter.cs" /> <Compile Include="Converters\StringToWordsConverter.cs" /> <Compile Include="Converters\TimeSpanToTwoDigitsTimeConverter.cs" /> <Compile Include="Converters\VersionToShortVersionConverter.cs" /> |
