Ver Fonte

Improvements to Drag & Drop and the NumberEdit

Kenric Nugteren há 1 ano atrás
pai
commit
fb17825305

+ 2 - 2
inabox.wpf/DynamicGrid/DynamicDocumentGrid.cs

@@ -220,7 +220,7 @@ namespace InABox.DynamicGrid
 
         public event OnGetWatermark OnGetWaterMark;
 
-        protected override void OnDragEnd(Type entity, CoreTable table)
+        protected override void OnDragEnd(Type entity, CoreTable table, DragEventArgs e)
         {
             if (entity == typeof(Document))
             {
@@ -257,7 +257,7 @@ namespace InABox.DynamicGrid
             }
             else
             {
-                base.OnDragEnd(entity, table);
+                base.OnDragEnd(entity, table, e);
             }
         }
 

+ 8 - 7
inabox.wpf/DynamicGrid/DynamicGrid.cs

@@ -3390,7 +3390,7 @@ namespace InABox.DynamicGrid
 
         private static string DragFormat => typeof(DynamicGridDragFormat).FullName ?? "";
 
-        protected virtual void OnDragEnd(Type entity, CoreTable table)
+        protected virtual void OnDragEnd(Type entity, CoreTable table, DragEventArgs e)
         {
             Logger.Send(LogType.Information,"","OnDragEnd");
         }
@@ -3416,7 +3416,7 @@ namespace InABox.DynamicGrid
                     {
                         if (column is DataColumn dataColumn)
                         {
-                            table.Columns.Add(new CoreColumn { ColumnName = dataColumn.ColumnName, DataType = dataColumn.DataType });
+                            table.Columns.Add(new CoreColumn { ColumnName = dataColumn.ColumnName.Replace('_', '.'), DataType = dataColumn.DataType });
                         }
                     }
                     foreach (var row in data.Table.Rows)
@@ -3429,28 +3429,29 @@ namespace InABox.DynamicGrid
                         }
                     }
 
-                    OnDragEnd(data.Entity, table);
+                    OnDragEnd(data.Entity, table, e);
                     DoChanged();
 
                 }
             }
         }
 
-        protected void DragTable(Type entity, CoreTable table)
+        protected DragDropEffects DragTable(Type entity, CoreTable table)
         {
             Logger.Send(LogType.Information,"","DragTable");
             var data = new DataObject();
             data.SetData(DragFormat, new DynamicGridDragFormat(table.ToDataTable(), entity));
-            DragDrop.DoDragDrop(this, data, DragDropEffects.All);
+            var effect = DragDrop.DoDragDrop(this, data, DragDropEffects.All);
+            return effect;
         }
 
-        protected virtual void OnRowsDragStart(CoreRow[] rows)
+        protected virtual DragDropEffects OnRowsDragStart(CoreRow[] rows)
         {
             Logger.Send(LogType.Information,"","OnRowsDragStart");
             var table = new CoreTable();
             table.LoadColumns(Data.Columns);
             table.LoadRows(rows);
-            DragTable(typeof(T), table);
+            return DragTable(typeof(T), table);
         }
 
         private void RowDragDropController_DragStart(object? sender, GridRowDragStartEventArgs e)

+ 9 - 2
inabox.wpf/Editors/NumberEdit.xaml.cs

@@ -25,8 +25,15 @@ namespace InABox.WPF
 
         private void OK_Click(object sender, RoutedEventArgs e)
         {
-            DialogResult = true;
-            Close();
+            if(Editor.Value >= Editor.Minimum && Editor.Value <= Editor.Maximum)
+            {
+                DialogResult = true;
+                Close();
+            }
+            else
+            {
+                MessageBox.Show($"Value must be in range [{Editor.Minimum}, {Editor.Maximum}]");
+            }
         }
 
         private void Cancel_Click(object sender, RoutedEventArgs e)