1234567891011121314151617181920212223242526272829303132333435363738 |
- namespace InABox.Core
- {
- public class DFLayoutDoubleFieldProperties : DFLayoutFieldProperties<double>
- {
- public DFLayoutDoubleFieldProperties()
- {
- Format = "F2";
- }
- public string Format { get; set; }
- public override string FormatValue(object value)
- {
- return string.Format("{0" + (string.IsNullOrWhiteSpace(Format) ? "" : ":" + Format) + "}", value);
- }
- public override object? ParseValue(object value)
- {
- if (value is double)
- return value;
- if (double.TryParse(value as string, out var result))
- return result;
- return null;
- }
- protected override void LoadProperties()
- {
- base.LoadProperties();
- Format = GetProperty("Format", Format);
- }
- protected override void SaveProperties()
- {
- base.SaveProperties();
- SetProperty("Format", Format);
- }
- }
- }
|