Browse Source

DOCUMENT EDITOR - sort according to superceded for multiple docs

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
4e4d8f50f9
1 changed files with 23 additions and 4 deletions
  1. 23 4
      inabox.wpf/DynamicGrid/PDF/DocumentEditor.xaml.cs

+ 23 - 4
inabox.wpf/DynamicGrid/PDF/DocumentEditor.xaml.cs

@@ -1,5 +1,7 @@
-using System.ComponentModel;
+using System.Collections.Generic;
+using System.ComponentModel;
 using System.IO;
 using System.IO;
+using System.Linq;
 using System.Windows;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using InABox.Core;
 using InABox.Core;
@@ -21,6 +23,26 @@ namespace InABox.DynamicGrid
             SaveAllowed = false;
             SaveAllowed = false;
             InitializeComponent();
             InitializeComponent();
             _documents = documents;
             _documents = documents;
+
+            CreateTabs(CheckSuperceded(documents));
+
+            bReady = true;
+
+            Documents.SelectedIndex = -1;
+        }
+
+        private List<IEntityDocument> CheckSuperceded(IEntityDocument[] documents)
+        {
+            var docs = documents.ToList();
+            if (docs.Count() > 1)
+            {              
+                docs.Sort((x, y) => x.Superceded.CompareTo(y.Superceded)); //ascending
+            }
+            return docs;
+        }
+
+        private void CreateTabs(List<IEntityDocument> documents)
+        {
             foreach (var doc in documents)
             foreach (var doc in documents)
             {
             {
                 var tab = new DynamicTabItem();
                 var tab = new DynamicTabItem();
@@ -29,9 +51,6 @@ namespace InABox.DynamicGrid
                 Documents.Items.Add(tab);
                 Documents.Items.Add(tab);
             }
             }
 
 
-            bReady = true;
-
-            Documents.SelectedIndex = -1;
         }
         }
 
 
         //public bool PrintAllowed { get; set; }
         //public bool PrintAllowed { get; set; }