Selaa lähdekoodia

Fixed some bugs with DynamicGridColumns nto being constructed correctly.

Kenric Nugteren 4 kuukautta sitten
vanhempi
commit
5979d78d79

+ 4 - 7
prs.desktop/Forms/Export/ExportGrid.cs

@@ -51,13 +51,10 @@ internal class ExportGrid : DynamicGrid<ExportColumn>
 
     private DynamicGridColumns ExportGrid_OnLoadColumns(object sender, DynamicGridColumns master)
     {
-        var columns = new DynamicGridColumns();
-        columns.Add(new DynamicGridColumn { ColumnName = "Name", /* Type = typeof(String), */ Width = 0 });
-
-        var col = new DynamicGridColumn { ColumnName = "Property", /* Type = typeof(String), */ Width = 0 };
-        columns.Add(col);
-
-        columns.Add(new DynamicGridColumn { ColumnName = "Format", /* Type = typeof(String), */ Width = 50 });
+        var columns = new DynamicGridColumns<ExportColumn>();
+        columns.Add(x => x.Name, width: 0);
+        columns.Add(x => x.Property, width: 0);
+        columns.Add(x => x.Format, width: 50);
         return columns;
     }
 

+ 2 - 2
prs.desktop/ModuleConfigurationWindow.xaml.cs

@@ -105,8 +105,8 @@ public class ModuleGrid : DynamicGrid<ModuleItem>
 
     protected override DynamicGridColumns LoadColumns()
     {
-        var columns = new DynamicGridColumns();
-        columns.Add(new DynamicGridColumn { ColumnName = "Description", Caption = "Description", Width = 0, Alignment = Alignment.MiddleLeft });
+        var columns = new DynamicGridColumns<ModuleItem>();
+        columns.Add(x => x.Description, width: 0, alignment: Alignment.MiddleLeft);
         return columns;
     }
 }

+ 5 - 5
prs.desktop/Panels/Factory/ManufacturingTreatmentGrid.cs

@@ -12,11 +12,11 @@ public class ManufacturingTreatmentGrid : DynamicGrid<ManufacturingTreatment>
 
     protected override DynamicGridColumns LoadColumns()
     {
-        var result = new DynamicGridColumns();
-        result.Add(new DynamicGridColumn { ColumnName = "Packet.SetoutLink.JobLink.JobNumber", Caption = "Job", Width = 80 });
-        result.Add(new DynamicGridColumn { ColumnName = "Packet.Serial", Caption = "Serial", Width = 150 });
-        result.Add(new DynamicGridColumn { ColumnName = "Packet.Title", Caption = "Title", Width = 0 });
-        result.Add(new DynamicGridColumn { ColumnName = "Packet.Quantity", Caption = "Qty", Width = 70, Alignment = Alignment.MiddleCenter });
+        var result = new DynamicGridColumns<ManufacturingTreatment>();
+        result.Add(x => x.Packet.SetoutLink.JobLink.JobNumber, caption: "Job", width: 80);
+        result.Add(x => x.Packet.Serial, caption: "Serial", width: 150);
+        result.Add(x => x.Packet.Title, caption: "Title", width: 0);
+        result.Add(x => x.Packet.Quantity, caption: "Qty", width: 70, alignment: Alignment.MiddleCenter);
         return result;
     }
 

+ 5 - 23
prs.desktop/Panels/Jobs/DocumentSets/JobDocumentSetMilestoneTasks.cs

@@ -114,29 +114,11 @@ public class JobDocumentSetMilestoneTasks : DynamicDataGrid<JobDocumentSetMileSt
 
     protected override DynamicGridColumns LoadColumns()
     {
-        return new DynamicGridColumns()
-        {
-            new DynamicGridColumn()
-            {
-                ColumnName = CoreUtils.GetFullPropertyName<JobDocumentSetMileStoneKanban, int>(x => x.Kanban.Number, "."), 
-                Caption = "#",
-                Width = 50,
-                Alignment = Alignment.MiddleCenter
-            },
-            new DynamicGridColumn()
-            {
-                ColumnName = CoreUtils.GetFullPropertyName<JobDocumentSetMileStoneKanban, String>(x => x.Kanban.Title, "."), 
-                Caption = "Title",
-                Width = 0
-            },
-            new DynamicGridColumn()
-            {
-                ColumnName = CoreUtils.GetFullPropertyName<JobDocumentSetMileStoneKanban, KanbanStatus>(x => x.Kanban.Status, "."), 
-                Caption = "Status",
-                Width = 70,
-                Alignment = Alignment.MiddleCenter
-            }
-        };
+        var columns = new DynamicGridColumns<JobDocumentSetMileStoneKanban>();
+        columns.Add(x => x.Kanban.Number, caption: "#", width: 50, alignment: Alignment.MiddleCenter);
+        columns.Add(x => x.Kanban.Title, caption: "Title", width: 0);
+        columns.Add(x => x.Kanban.Status, caption: "Status", width: 70, alignment: Alignment.MiddleCenter);
+        return columns;
     }
 
     // private readonly BitmapImage _status = PRSDesktop.Resources.tick.AsBitmapImage();

+ 3 - 8
prs.desktop/Panels/Meeting/MeetingAssignmentGrid.cs

@@ -28,14 +28,9 @@ namespace PRSDesktop
 
         protected override DynamicGridColumns LoadColumns()
         {
-            return new DynamicGridColumns()
-            {
-                new DynamicGridColumn()
-                {
-                    ColumnName = CoreUtils.GetFullPropertyName<Assignment, String>(x => x.EmployeeLink.Name, "."), 
-                    Width = 0
-                }
-            };
+            var columns = new DynamicGridColumns<Assignment>();
+            columns.Add(x => x.EmployeeLink.Name);
+            return columns;
         }
 
         protected override void Reload(

+ 3 - 8
prs.desktop/Panels/Meeting/MeetingItemDocumentGrid.cs

@@ -32,14 +32,9 @@ namespace PRSDesktop
 
         protected override DynamicGridColumns LoadColumns()
         {
-            return new DynamicGridColumns()
-            {
-                new DynamicGridColumn()
-                {
-                    ColumnName = CoreUtils.GetFullPropertyName<MeetingItemDocument, String>(x => x.DocumentLink.FileName, "."), 
-                    Width = 0
-                }
-            };
+            var columns = new DynamicGridColumns<MeetingItemDocument>();
+            columns.Add(x => x.DocumentLink.FileName);
+            return columns;
         }
         
         protected override bool CanCreateItems()

+ 5 - 18
prs.desktop/Panels/Meeting/MeetingItemTaskGrid.cs

@@ -90,24 +90,11 @@ namespace PRSDesktop
 
         protected override DynamicGridColumns LoadColumns()
         {
-            return new DynamicGridColumns()
-            {
-                new DynamicGridColumn()
-                {
-                    ColumnName = CoreUtils.GetFullPropertyName<MeetingItemKanban, int>(x => x.Kanban.Number, "."), 
-                    Width = 50
-                },
-                new DynamicGridColumn()
-                {
-                    ColumnName = CoreUtils.GetFullPropertyName<MeetingItemKanban, String>(x => x.Kanban.Title, "."), 
-                    Width = 0
-                },
-                new DynamicGridColumn()
-                {
-                ColumnName = CoreUtils.GetFullPropertyName<MeetingItemKanban, String>(x => x.Kanban.EmployeeLink.Code, "."), 
-                Width = 100
-            }
-            };
+            var columns = new DynamicGridColumns<MeetingItemKanban>();
+            columns.Add(x => x.Kanban.Number, width: 50);
+            columns.Add(x => x.Kanban.Title, width: 0);
+            columns.Add(x => x.Kanban.EmployeeLink.Code, width: 100);
+            return columns;
         }
 
         private readonly BitmapImage _status = PRSDesktop.Resources.tick.AsBitmapImage();

+ 5 - 6
prs.desktop/Panels/Security/Global/GlobalTokenGrid.cs

@@ -63,12 +63,11 @@ public class GlobalTokenGrid : DynamicGrid<SecurityDescriptor>
 
     protected override DynamicGridColumns LoadColumns()
     {
-        var columns = new DynamicGridColumns
-        {
-            new DynamicGridColumn { ColumnName = "Group", Caption = "Group", Width = 150, Alignment = Alignment.MiddleCenter },
-            new DynamicGridColumn { ColumnName = "Description", Caption = "Description", Width = 0, Alignment = Alignment.MiddleLeft },
-            new DynamicGridColumn { ColumnName = "Category", Caption = "Applies To", Width = 200, Alignment = Alignment.MiddleCenter }
-        };
+
+        var columns = new DynamicGridColumns<SecurityDescriptor>();
+        columns.Add(x => x.Group, width: 150, alignment: Alignment.MiddleCenter);
+        columns.Add(x => x.Description, width: 0, alignment: Alignment.MiddleLeft);
+        columns.Add(x => x.Category, width: 200, alignment: Alignment.MiddleCenter);
 
         ActionColumns.Clear();
 

+ 4 - 5
prs.shared/Grids/EventGrid.cs

@@ -42,18 +42,17 @@ public class EventGrid : DynamicDataGrid<Event>
             EnableButton = AddButton("Disable", null, Enable_Click);
             EnableButton.Visibility = Visibility.Collapsed;
         }
-
-        OnSelectItem += EventGrid_OnSelectItem;
     }
 
-    private void EventGrid_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
+    protected override void SelectItems(CoreRow[]? rows)
     {
+        base.SelectItems(rows);
         if(EnableButton is not null)
         {
-            if(e.Rows is not null && e.Rows.Length > 0)
+            if(rows is not null && rows.Length > 0)
             {
                 EnableButton.Visibility = Visibility.Visible;
-                EnableButton.Content = e.Rows.Any(x => !x.Get<Event, bool>(x => x.Enabled))
+                EnableButton.Content = rows.Any(x => !x.Get<Event, bool>(x => x.Enabled))
                     ? "Enable" : "Disable";
             }
             else