Explorar el Código

Switched Add Task Field to now deal in strings

Kenric Nugteren hace 1 año
padre
commit
cf6d84a69a

+ 6 - 6
prs.classes/FormFields/DFLayoutAddTaskField/DFLayoutAddTaskFieldProperties.cs

@@ -8,7 +8,7 @@ using System.Text;
 
 namespace PRSClasses
 {
-    public class DFLayoutAddTaskFieldProperties : DFLayoutFieldProperties<int?, int?>
+    public class DFLayoutAddTaskFieldProperties : DFLayoutFieldProperties<string?, string?>
     {
         public KanbanTypeLink TaskType { get; set; }
 
@@ -30,22 +30,22 @@ namespace PRSClasses
             SetProperty("TaskType", TaskType.ID);
         }
 
-        public override int? DeserializeValue(DFLoadStorageEntry entry)
+        public override string? DeserializeValue(DFLoadStorageEntry entry)
         {
-            return entry.GetValue<int?>();
+            return entry.GetValue<string>();
         }
 
-        public override void SerializeValue(DFSaveStorageEntry entry, int? value)
+        public override void SerializeValue(DFSaveStorageEntry entry, string? value)
         {
             entry.SetValue(value);
         }
 
-        public override int? GetValue(int? value)
+        public override string? GetValue(string? value)
         {
             return value;
         }
 
-        public override string FormatValue(object? value)
+        public override string FormatValue(string? value)
         {
             return string.Format("{0}", value);
         }

+ 14 - 7
prs.shared/FormFields/DFAddTaskControl.cs

@@ -16,7 +16,7 @@ using TextBox = System.Windows.Controls.TextBox;
 
 namespace PRS.Shared
 {
-    public class DFAddTaskControl : DynamicFormFieldControl<DFLayoutAddTaskField, DFLayoutAddTaskFieldProperties, int?, int?>
+    public class DFAddTaskControl : DynamicFormFieldControl<DFLayoutAddTaskField, DFLayoutAddTaskFieldProperties, string?, string?>
     {
         private IntegerTextBox Number = null!; // Late-initialisation
         private Button Button = null!; // Late-initialisation
@@ -62,24 +62,31 @@ namespace PRS.Shared
             }
         }
 
-        public override int? GetSerializedValue()
+        public override string? GetSerializedValue()
         {
             return GetValue();
         }
 
-        public override void SetSerializedValue(int? value)
+        public override void SetSerializedValue(string? value)
         {
             SetValue(value);
         }
 
-        public override int? GetValue()
+        public override string? GetValue()
         {
-            return Number.Value.HasValue ? Convert.ToInt32(Number.Value.Value) : null;
+            return Number.Value?.ToString();
         }
 
-        public override void SetValue(int? value)
+        public override void SetValue(string? value)
         {
-            Number.Value = value;
+            if(int.TryParse(value, out var i))
+            {
+                Number.Value = i;
+            }
+            else
+            {
+                Number.Value = null;
+            }
             Button.IsEnabled = FormDesignGrid.IsEditing && value == null;
         }