|
@@ -0,0 +1,115 @@
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Media;
|
|
|
+using InABox.Core;
|
|
|
+using Syncfusion.Windows.Data;
|
|
|
+
|
|
|
+namespace InABox.DynamicGrid;
|
|
|
+
|
|
|
+
|
|
|
+public class ListEditorControl : DynamicEditorControl<IList, ListEditor>
|
|
|
+{
|
|
|
+ static ListEditorControl()
|
|
|
+ {
|
|
|
+ //DynamicEditorControlFactory.Register<ButtonEditorControl, ButtonEditor>();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public ListEditorControl()
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ private Button Editor;
|
|
|
+
|
|
|
+ private IList? _data;
|
|
|
+
|
|
|
+ public int ListWidth { get; set; }
|
|
|
+
|
|
|
+ public int ListHeight { get; set; }
|
|
|
+
|
|
|
+ public bool DirectEdit { get; set; }
|
|
|
+
|
|
|
+ protected override FrameworkElement CreateEditor()
|
|
|
+ {
|
|
|
+ Editor = new Button
|
|
|
+ {
|
|
|
+ Content = EditorDefinition.Label,
|
|
|
+ HorizontalAlignment = HorizontalAlignment.Stretch,
|
|
|
+ VerticalAlignment = VerticalAlignment.Stretch,
|
|
|
+ VerticalContentAlignment = VerticalAlignment.Center,
|
|
|
+ };
|
|
|
+
|
|
|
+ Editor.Click += (sender, args) =>
|
|
|
+ {
|
|
|
+ if (_data == null)
|
|
|
+ return;
|
|
|
+ var type = _data.GetType().GetGenericArguments().First();
|
|
|
+ var gridtype = DynamicGridUtils.FindDynamicGrid(typeof(DynamicItemsListGrid<>), type);
|
|
|
+ BaseDynamicGrid? grid = Activator.CreateInstance(gridtype) as BaseDynamicGrid;
|
|
|
+ if (grid is not IDynamicItemsListGrid idg )
|
|
|
+ return;
|
|
|
+ idg.Items = _data;
|
|
|
+ grid.OnReconfigure += options =>
|
|
|
+ {
|
|
|
+ options
|
|
|
+ .Add(DynamicGridOption.AddRows)
|
|
|
+ .Add(DynamicGridOption.EditRows)
|
|
|
+ .Add(DynamicGridOption.DeleteRows)
|
|
|
+ .Add(DynamicGridOption.RecordCount);
|
|
|
+ if (DirectEdit)
|
|
|
+ options.Add(DynamicGridOption.DirectEdit);
|
|
|
+ };
|
|
|
+ grid.Reconfigure();
|
|
|
+ var window = DynamicGridUtils.CreateGridWindow("License Mappings", grid);
|
|
|
+ if (ListWidth > 0)
|
|
|
+ window.Width = ListWidth;
|
|
|
+ if (ListHeight > 0)
|
|
|
+ window.Height = ListHeight;
|
|
|
+ window.ShowDialog();
|
|
|
+ };
|
|
|
+
|
|
|
+ return Editor;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void Configure()
|
|
|
+ {
|
|
|
+ if (EditorDefinition is not ListEditor editor)
|
|
|
+ return;
|
|
|
+ ListWidth = editor.ListWidth;
|
|
|
+ ListHeight = editor.ListHeight;
|
|
|
+ DirectEdit = editor.DirectEdit;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override int DesiredHeight()
|
|
|
+ {
|
|
|
+ return 25;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override int DesiredWidth()
|
|
|
+ {
|
|
|
+ return 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override IList RetrieveValue()
|
|
|
+ {
|
|
|
+ return _data;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void UpdateValue(IList value)
|
|
|
+ {
|
|
|
+ _data = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetFocus()
|
|
|
+ {
|
|
|
+ Editor.Focus();
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void SetColor(Color color)
|
|
|
+ {
|
|
|
+ }
|
|
|
+}
|