|
@@ -15,6 +15,8 @@ using Syncfusion.Data.Extensions;
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Data;
|
|
|
using System.Windows.Media;
|
|
|
+using AutoProperties;
|
|
|
+using InABox.WPF;
|
|
|
|
|
|
namespace InABox.DynamicGrid;
|
|
|
|
|
@@ -466,33 +468,80 @@ public static class DynamicGridUtils
|
|
|
}
|
|
|
return gridType.MakeGenericType(entityType);
|
|
|
}
|
|
|
-
|
|
|
- public static Window CreateGridWindow(string title, IDynamicGrid dynamicGrid)
|
|
|
+
|
|
|
+ public static Window CreateGridWindow(string title, IDynamicGrid dynamicGrid, bool showbuttons = false, Func<bool>? okclicked = null)
|
|
|
{
|
|
|
dynamicGrid.Margin = new Thickness(5);
|
|
|
+
|
|
|
+ var window = new ThemableWindow { Title = title };
|
|
|
+ window.SetValue(WindowBehavior.HideCloseButtonProperty, showbuttons);
|
|
|
+
|
|
|
+ var grid = new Grid();
|
|
|
+ grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
|
|
|
+ grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
|
|
|
+ grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
|
|
|
+ grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
|
|
|
+ grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
|
|
|
+
|
|
|
+ var fe = dynamicGrid as FrameworkElement;
|
|
|
+ fe.SetValue(Grid.RowProperty,0);
|
|
|
+ fe.SetValue(Grid.ColumnProperty, 0);
|
|
|
+ fe.SetValue(Grid.ColumnSpanProperty, 3);
|
|
|
+ grid.Children.Add(fe);
|
|
|
|
|
|
- var window = new ThemableWindow { Title = title, Content = dynamicGrid };
|
|
|
-
|
|
|
+ if (showbuttons)
|
|
|
+ {
|
|
|
+ var ok = new Button();
|
|
|
+ ok.Content = "OK";
|
|
|
+ ok.SetValue(Grid.RowProperty,1);
|
|
|
+ ok.SetValue(Grid.ColumnProperty,1);
|
|
|
+ ok.Margin = new Thickness(0,0,5,5);
|
|
|
+ ok.Width = 80;
|
|
|
+ ok.Height = 35;
|
|
|
+ ok.Click += (sender, args) =>
|
|
|
+ {
|
|
|
+ if (okclicked?.Invoke() ?? true)
|
|
|
+ window.DialogResult = true;
|
|
|
+ };
|
|
|
+ grid.Children.Add(ok);
|
|
|
+
|
|
|
+ var cancel = new Button();
|
|
|
+ cancel.Content = "Cancel";
|
|
|
+ cancel.SetValue(Grid.RowProperty,1);
|
|
|
+ cancel.SetValue(Grid.ColumnProperty,2);
|
|
|
+ cancel.Margin = new Thickness(0,0,5,5);
|
|
|
+ cancel.Width = 80;
|
|
|
+ cancel.Height = 35;
|
|
|
+ cancel.Click += (sender, args) =>
|
|
|
+ {
|
|
|
+ window.DialogResult = false;
|
|
|
+ };
|
|
|
+ grid.Children.Add(cancel);
|
|
|
+ }
|
|
|
+
|
|
|
+ window.Content = grid;
|
|
|
+
|
|
|
dynamicGrid.Refresh(true, true);
|
|
|
|
|
|
return window;
|
|
|
}
|
|
|
- public static Window CreateGridWindow(string title, Type entityType, Type? gridType = null)
|
|
|
+
|
|
|
+ public static Window CreateGridWindow(string title, Type entityType, Type? gridType = null, bool showbuttons = false)
|
|
|
{
|
|
|
gridType ??= typeof(DynamicGrid<>);
|
|
|
var grid = CreateDynamicGrid(gridType, entityType);
|
|
|
- return CreateGridWindow(title, grid);
|
|
|
+ return CreateGridWindow(title, grid, showbuttons);
|
|
|
}
|
|
|
- public static Window CreateGridWindow<TGrid, TEntity>(string title)
|
|
|
+ public static Window CreateGridWindow<TGrid, TEntity>(string title, bool showbuttons = false)
|
|
|
where TEntity : BaseObject
|
|
|
where TGrid : IDynamicGrid
|
|
|
{
|
|
|
- return CreateGridWindow(title, typeof(TEntity), typeof(TGrid));
|
|
|
+ return CreateGridWindow(title, typeof(TEntity), typeof(TGrid), showbuttons);
|
|
|
}
|
|
|
- public static Window CreateGridWindow<TEntity>(string title)
|
|
|
+ public static Window CreateGridWindow<TEntity>(string title, bool showbuttons = false)
|
|
|
where TEntity : BaseObject
|
|
|
{
|
|
|
- return CreateGridWindow(title, typeof(TEntity));
|
|
|
+ return CreateGridWindow(title, typeof(TEntity), null, showbuttons);
|
|
|
}
|
|
|
|
|
|
#endregion
|