diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-01-22 18:00:55 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-01-22 18:00:55 +0200 |
| commit | bf432bf7b7faa7c51e74462e19eb3e50c28b4aa8 (patch) | |
| tree | 2cce2090c2455f2cadc3f8288f05688ae60a9ed5 /Software/Visual_Studio/Tango.Core | |
| parent | 287af6d4bed5333087cb9d702d20035b1ad9a326 (diff) | |
| download | Tango-bf432bf7b7faa7c51e74462e19eb3e50c28b4aa8.tar.gz Tango-bf432bf7b7faa7c51e74462e19eb3e50c28b4aa8.zip | |
Implemented StringFormat control for db properties.
Added StringFormat 0.000 for FeederTension on ProcessParameters.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core')
4 files changed, 46 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Core/CustomAttributes/StringFormatAttribute.cs b/Software/Visual_Studio/Tango.Core/CustomAttributes/StringFormatAttribute.cs new file mode 100644 index 000000000..e7089b64d --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/CustomAttributes/StringFormatAttribute.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Core.CustomAttributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class StringFormatAttribute : Attribute + { + public String Format { get; set; } + + public StringFormatAttribute() + { + Format = "0.0"; + } + + public StringFormatAttribute(String format) : this() + { + Format = format; + } + } +} diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs index 7107b9ee9..4850ccc25 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IParameterizedExtensions.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using Tango.Core; +using Tango.Core.CustomAttributes; /// <summary> /// Contains extension methods for <see cref="IParameterized"/>. @@ -112,6 +113,12 @@ public static class IParameterizedExtensions item.Minimum = rangeAtt.Minimum; item.Maximum = rangeAtt.Maximum; } + + StringFormatAttribute formatAtt = propertyInfo.GetCustomAttribute<StringFormatAttribute>(); + if (formatAtt != null) + { + item.StringFormat = formatAtt.Format; + } } if (mode == ParameterItemMode.Event) diff --git a/Software/Visual_Studio/Tango.Core/ParameterItem.cs b/Software/Visual_Studio/Tango.Core/ParameterItem.cs index ee7acfdd0..0ce682e01 100644 --- a/Software/Visual_Studio/Tango.Core/ParameterItem.cs +++ b/Software/Visual_Studio/Tango.Core/ParameterItem.cs @@ -138,6 +138,19 @@ namespace Tango.Core /// <summary> + /// Gets or sets the parameter string format. + /// </summary> + public String StringFormat + { + get { return (String)GetValue(StringFormatProperty); } + set { SetValue(StringFormatProperty, value); } + } + public static readonly DependencyProperty StringFormatProperty = + DependencyProperty.Register("StringFormat", typeof(String), typeof(ParameterItem), new PropertyMetadata("0.0")); + + + + /// <summary> /// Gets a value indicating whether this instance requires custom editor. /// </summary> public bool HasCustomEditor diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 54d7e3259..1dc51c2cf 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -89,6 +89,7 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="Components\CmdCommand.cs" /> + <Compile Include="CustomAttributes\StringFormatAttribute.cs" /> <Compile Include="ExtensionMethods\ByteArrayExtensions.cs" /> <Compile Include="IO\KnownFolders.cs" /> <Compile Include="Json\ProtobufContractResolver.cs" /> @@ -200,7 +201,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> <Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> |
