DynamicGridColumnsEditor.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using InABox.Core;
  2. using InABox.Wpf;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. namespace InABox.DynamicGrid;
  8. /// <summary>
  9. /// Interaction logic for DynamicGridColumnsEditor.xaml
  10. /// </summary>
  11. public partial class DynamicGridColumnsEditor : ThemableWindow
  12. {
  13. private readonly DynamicColumnGrid ColumnGrid;
  14. public event GetAvailableColumnsEvent? GetAvailableColumns
  15. {
  16. add => ColumnGrid.OnProcessColumns += value;
  17. remove => ColumnGrid.OnProcessColumns -= value;
  18. }
  19. public DynamicGridColumnsEditor(Type type)
  20. {
  21. InitializeComponent();
  22. Type = type;
  23. Title = $"Select Columns for {CoreUtils.Neatify(type.Name)}";
  24. ColumnGrid = new DynamicColumnGrid { Type = type };
  25. ColumnGrid.SetValue(Grid.ColumnSpanProperty, 3);
  26. ColumnGrid.Margin = new Thickness(5F, 5F, 5F, 5F);
  27. grid.Children.Add(ColumnGrid);
  28. Columns = ColumnGrid.Columns;
  29. //ColumnGrid.OnEditItem += Columns_OnEditItem;
  30. }
  31. public Type Type { get; set; }
  32. public DynamicGridColumns Columns { get; }
  33. public bool DirectEdit
  34. {
  35. get => ColumnGrid.DirectEdit;
  36. set => ColumnGrid.DirectEdit = value;
  37. }
  38. //private bool Columns_OnEditItem(object sender, object item)
  39. //{
  40. // DynamicEditor editor = new DynamicEditor();
  41. // editor.OnDefineGridColumns += Editor_OnDefineGridColumns;
  42. // editor.Item = item;
  43. // if (editor.ShowDialog() == true)
  44. // return true;
  45. // return false;
  46. //}
  47. //private DynamicGridColumns Editor_OnDefineGridColumns(object sender, DynamicGridColumns master)
  48. //{
  49. // return ColumnGrid.DefineColumns();
  50. //}
  51. private void OKButton_Click(object sender, RoutedEventArgs e)
  52. {
  53. DialogResult = true;
  54. Close();
  55. }
  56. private void CancelButton_Click(object sender, RoutedEventArgs e)
  57. {
  58. DialogResult = false;
  59. Close();
  60. }
  61. private void Window_Loaded(object sender, RoutedEventArgs e)
  62. {
  63. ColumnGrid.Type = Type;
  64. ColumnGrid.Refresh(true, true);
  65. }
  66. }