瀏覽代碼

PRS DESKTOP - fix to Job Doc screen scroll lag (converters)

Nick-PRSDigital@bitbucket.org 2 年之前
父節點
當前提交
04b7ee37d5

+ 1 - 1
prs.desktop/Panels/Jobs/DocumentSets/JobDocumentSetGrid.xaml.cs

@@ -53,7 +53,7 @@ namespace PRSDesktop
                 if (String.Equals(parameter, "Date"))
                 if (String.Equals(parameter, "Date"))
                     return String.Format("{0:dd MMM yy}", block.Date);
                     return String.Format("{0:dd MMM yy}", block.Date);
                 if (String.Equals(parameter, "Color"))
                 if (String.Equals(parameter, "Color"))
-                    return ImageUtils.ColorToString(block.Color);
+                    return "Red"; //ImageUtils.ColorToString(block.Color);
 
 
                 return parameter.ToString();
                 return parameter.ToString();
             }
             }

+ 76 - 33
prs.desktop/Panels/Jobs/DocumentSets/JobDocumentSetMileStoneConverter.cs

@@ -10,10 +10,10 @@ using InABox.WPF;
 
 
 namespace PRSDesktop
 namespace PRSDesktop
 {
 {
-    
+
     public class JobDocumentSetMileStoneConverter : IValueConverter
     public class JobDocumentSetMileStoneConverter : IValueConverter
     {
     {
-        
+
         private static Dictionary<JobDocumentSetMileStoneStatus, System.Drawing.Color> _statuscolors = new Dictionary<JobDocumentSetMileStoneStatus, Color>()
         private static Dictionary<JobDocumentSetMileStoneStatus, System.Drawing.Color> _statuscolors = new Dictionary<JobDocumentSetMileStoneStatus, Color>()
         {
         {
             { JobDocumentSetMileStoneStatus.Unknown, System.Drawing.Color.Red },
             { JobDocumentSetMileStoneStatus.Unknown, System.Drawing.Color.Red },
@@ -27,45 +27,73 @@ namespace PRSDesktop
             { JobDocumentSetMileStoneStatus.Cancelled, System.Drawing.Color.Gray },
             { JobDocumentSetMileStoneStatus.Cancelled, System.Drawing.Color.Gray },
 
 
         };
         };
-    
+
         public object Convert(object value, Type t, object parameter, CultureInfo culture)
         public object Convert(object value, Type t, object parameter, CultureInfo culture)
         {
         {
             try
             try
             {
             {
-                if ((value == null) || String.Equals(value,""))
-                    return "";
-                
-                var block = Serialization.Deserialize<JobDocumentSetMileStoneBlock>(value.ToString());
-                
-                if (String.Equals(parameter, "ID"))
-                    return block.ID;
-                if (String.Equals(parameter, "Revision"))
-                    return String.IsNullOrWhiteSpace(block.Revision) 
-                        ? "--" 
-                        : String.Format("Rev {0}",block.Revision);
-                
-                if (String.Equals(parameter, "Status"))
-                    return block.Status.ToString().SplitCamelCase();
-                if (String.Equals(parameter, "Color"))
-                    return ImageUtils.ColorToString(_statuscolors[block.Status]);
-                
-                if (String.Equals(parameter, "Date"))
-                    return String.Format("{0:dd MMM yy}", block.Date);
-                
-                if (String.Equals(parameter, "Notes"))
-                    return block.Notes;
-                if (String.Equals(parameter, "NotesColor"))
-                    return String.IsNullOrWhiteSpace(block.Notes)
+                switch (parameter)
+                {
+                    case "ID":
+                        if (ValidJson(value))
+                            return GetBlock(value).ID;
+                        else
+                            return Guid.Empty;
+
+                    case "Revision":
+                        if (ValidJson(value))
+                            return String.IsNullOrWhiteSpace(GetBlock(value).Revision)
+                        ? "--"
+                        : String.Format("Rev {0}", GetBlock(value).Revision);
+                        else
+                            return "";
+
+                    case "Status":
+                        if (ValidJson(value))
+                            return GetBlock(value).Status.ToString().SplitCamelCase();
+                        else
+                            return "";
+
+                    case "Color":
+                        if (ValidJson(value))
+                            return ImageUtils.ColorToString(_statuscolors[GetBlock(value).Status]);
+                        else
+                            return ImageUtils.ColorToString(Color.White);
+
+                    case "Date":
+                        if (ValidJson(value))
+                            return String.Format("{0:dd MMM yy}", GetBlock(value).Date);
+                        else
+                            return "";
+
+                    case "Notes":
+                        if (ValidJson(value))
+                            return GetBlock(value).Notes;
+                        else
+                            return "";
+
+                    case "NotesColor":
+                        if (ValidJson(value))
+                            return String.IsNullOrWhiteSpace(GetBlock(value).Notes)
                         ? ImageUtils.ColorToString(Color.Transparent)
                         ? ImageUtils.ColorToString(Color.Transparent)
                         : ImageUtils.ColorToString(Color.Orchid);
                         : ImageUtils.ColorToString(Color.Orchid);
-                        
-                if (String.Equals(parameter, "Attachments"))
-                    return String.Format("{0} files attached", block.Attachments);
-                if (String.Equals(parameter, "AttachmentsColor"))
-                    return block.Attachments == 0 
+                        else
+                            return ImageUtils.ColorToString(Color.Transparent);
+
+                    case "Attachments":
+                        if (ValidJson(value))
+                            return String.Format("{0} files attached", GetBlock(value).Attachments);
+                        else
+                            return "";
+
+                    case "AttachmeentsColor":
+                        if (ValidJson(value))
+                            return GetBlock(value).Attachments == 0
                         ? ImageUtils.ColorToString(Color.Transparent)
                         ? ImageUtils.ColorToString(Color.Transparent)
                         : ImageUtils.ColorToString(Color.CornflowerBlue);
                         : ImageUtils.ColorToString(Color.CornflowerBlue);
-                
+                        else
+                            return ImageUtils.ColorToString(Color.Transparent);
+                }
 
 
                 return parameter.ToString();
                 return parameter.ToString();
             }
             }
@@ -75,6 +103,21 @@ namespace PRSDesktop
             }
             }
         }
         }
 
 
+        private JobDocumentSetMileStoneBlock? GetBlock(object value)
+        {
+            return Serialization.Deserialize<JobDocumentSetMileStoneBlock>(value.ToString());
+        }
+
+        private bool ValidJson(object value)
+        {
+            if (value == null)
+                return false;
+            if (value == "")
+                return false;
+            else
+                return true;
+        }
+
         public object ConvertBack(object value, Type t, object parameter, CultureInfo culture)
         public object ConvertBack(object value, Type t, object parameter, CultureInfo culture)
         {
         {
             return value.Equals(false) ? DependencyProperty.UnsetValue : parameter;
             return value.Equals(false) ? DependencyProperty.UnsetValue : parameter;