Prechádzať zdrojové kódy

DOCUMENT EDITOR - sort according to superceded for multiple docs

Nick-PRSDigital@bitbucket.org 2 rokov pred
rodič
commit
4e4d8f50f9

+ 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.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using InABox.Core;
@@ -21,6 +23,26 @@ namespace InABox.DynamicGrid
             SaveAllowed = false;
             InitializeComponent();
             _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)
             {
                 var tab = new DynamicTabItem();
@@ -29,9 +51,6 @@ namespace InABox.DynamicGrid
                 Documents.Items.Add(tab);
             }
 
-            bReady = true;
-
-            Documents.SelectedIndex = -1;
         }
 
         //public bool PrintAllowed { get; set; }