|
@@ -495,7 +495,20 @@ namespace InABox.DynamicGrid
|
|
|
DataGrid.ColumnSizer = GridLengthUnitType.AutoLastColumnFill;
|
|
|
DataGrid.SelectionForegroundBrush = BaseDynamicGrid.SelectionForeground;
|
|
|
DataGrid.RowSelectionBrush = BaseDynamicGrid.SelectionBackground;
|
|
|
-
|
|
|
+
|
|
|
+ DataGrid.AllowDraggingRows = false;
|
|
|
+ DataGrid.Drop += DataGrid_Drop;
|
|
|
+ DataGrid.RowDragDropTemplate = TemplateGenerator.CreateDataTemplate(() =>
|
|
|
+ {
|
|
|
+ var border = new Border();
|
|
|
+ border.Width = 100;
|
|
|
+ border.Height = 100;
|
|
|
+ border.BorderBrush = new SolidColorBrush(Colors.Firebrick);
|
|
|
+ border.Background = new SolidColorBrush(Colors.Red);
|
|
|
+ border.CornerRadius = new CornerRadius(5);
|
|
|
+ return border;
|
|
|
+ });
|
|
|
+
|
|
|
DataGrid.CurrentCellBorderThickness = new Thickness(0);
|
|
|
DataGrid.AllowFiltering = false;
|
|
|
DataGrid.EnableDataVirtualization = true;
|
|
@@ -781,25 +794,23 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
if (Options.Contains(DynamicGridOption.DragSource))
|
|
|
{
|
|
|
- DataGrid.AllowDraggingRows = true;
|
|
|
- DataGrid.RowDragDropController.DragStart += RowDragDropController_DragStart;
|
|
|
- }
|
|
|
- else if (DataGrid.AllowDraggingRows)
|
|
|
- {
|
|
|
- DataGrid.AllowDraggingRows = false;
|
|
|
- DataGrid.RowDragDropController.DragStart -= RowDragDropController_DragStart;
|
|
|
- }
|
|
|
- if (Options.Contains(DynamicGridOption.DragTarget) && !DataGrid.AllowDrop)
|
|
|
- {
|
|
|
- DataGrid.Drop += DataGrid_Drop;
|
|
|
- DataGrid.AllowDrop = true;
|
|
|
+ if (!DataGrid.AllowDraggingRows)
|
|
|
+ {
|
|
|
+ DataGrid.AllowDraggingRows = true;
|
|
|
+ DataGrid.RowDragDropController.DragStart += RowDragDropController_DragStart;
|
|
|
+ }
|
|
|
}
|
|
|
- else if (DataGrid.AllowDrop)
|
|
|
+ else
|
|
|
{
|
|
|
- DataGrid.Drop -= DataGrid_Drop;
|
|
|
- DataGrid.AllowDrop = false;
|
|
|
+ if (DataGrid.AllowDraggingRows)
|
|
|
+ {
|
|
|
+ DataGrid.AllowDraggingRows = false;
|
|
|
+ DataGrid.RowDragDropController.DragStart -= RowDragDropController_DragStart;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ DataGrid.AllowDrop = Options.Contains(DynamicGridOption.DragTarget);
|
|
|
+
|
|
|
DataGrid.SelectionMode = Options.Contains(DynamicGridOption.MultiSelect) ? GridSelectionMode.Extended : GridSelectionMode.Single;
|
|
|
if (up != null)
|
|
|
up.Position = Options.Contains(DynamicGridOption.EditRows) ? DynamicActionColumnPosition.Start : DynamicActionColumnPosition.Hidden;
|
|
@@ -3596,15 +3607,25 @@ namespace InABox.DynamicGrid
|
|
|
|
|
|
protected virtual void OnDragEnd(Type entity, CoreTable table)
|
|
|
{
|
|
|
+ Logger.Send(LogType.Information,"","OnDragEnd");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void DataGrid_Drop(object sender, DragEventArgs e)
|
|
|
{
|
|
|
+ Logger.Send(LogType.Information,"","DataGrid_Drop");
|
|
|
+
|
|
|
+ if (!Options.Contains(DynamicGridOption.DragTarget))
|
|
|
+ return;
|
|
|
+
|
|
|
+ Logger.Send(LogType.Information,"","DataGrid_Drop::DragTarget==true");
|
|
|
+
|
|
|
if (e.Data.GetDataPresent(DragFormat))
|
|
|
{
|
|
|
+ Logger.Send(LogType.Information,"","DataGrid_Drop::DataPresent==true");
|
|
|
var data = e.Data.GetData(DragFormat) as DynamicGridDragFormat;
|
|
|
if (data is not null)
|
|
|
- {
|
|
|
+ {
|
|
|
+ Logger.Send(LogType.Information,"","DataGrid_Drop::DragData==DynamicGridDragFormat");
|
|
|
var table = new CoreTable();
|
|
|
foreach (var column in data.Table.Columns)
|
|
|
{
|
|
@@ -3624,41 +3645,46 @@ namespace InABox.DynamicGrid
|
|
|
}
|
|
|
|
|
|
OnDragEnd(data.Entity, table);
|
|
|
+ DoChanged();
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected void 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);
|
|
|
}
|
|
|
|
|
|
protected virtual void OnRowsDragStart(CoreRow[] rows)
|
|
|
{
|
|
|
+ Logger.Send(LogType.Information,"","OnRowsDragStart");
|
|
|
var table = new CoreTable();
|
|
|
-
|
|
|
table.LoadColumns(Data.Columns);
|
|
|
table.LoadRows(rows);
|
|
|
-
|
|
|
DragTable(typeof(T), table);
|
|
|
}
|
|
|
|
|
|
private void RowDragDropController_DragStart(object? sender, GridRowDragStartEventArgs e)
|
|
|
{
|
|
|
+ Logger.Send(LogType.Information,"","RowDragDropController_DragStart");
|
|
|
+ //e.Handled = true;
|
|
|
+
|
|
|
+ if (!Options.Contains(DynamicGridOption.DragSource))
|
|
|
+ return;
|
|
|
+
|
|
|
var rows = new List<CoreRow>();
|
|
|
foreach (var record in e.DraggingRecords)
|
|
|
{
|
|
|
var rowIndex = DataGrid.ResolveToRowIndex(record);
|
|
|
rows.Add(GetRowFromIndex(rowIndex));
|
|
|
}
|
|
|
-
|
|
|
var rowArr = rows.ToArray();
|
|
|
OnRowsDragStart(rowArr);
|
|
|
-
|
|
|
- e.Handled = true;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
#endregion
|