DynamicFormDesignWindow.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using InABox.Core;
  2. using Org.BouncyCastle.Bcpg;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. namespace InABox.DynamicGrid
  17. {
  18. /// <summary>
  19. /// Interaction logic for DynamicFormDesignWindow.xaml
  20. /// </summary>
  21. public partial class DynamicFormDesignWindow : DynamicFormWindow
  22. {
  23. public DynamicFormDesignWindow() : base()
  24. {
  25. InitializeComponent();
  26. Preview.Mode = FormMode.Designing;
  27. }
  28. protected override DynamicFormDesignGrid Grid { get => Preview; }
  29. public bool Designing
  30. {
  31. get => Grid.Mode == FormMode.Designing;
  32. set
  33. {
  34. Grid.Mode = value
  35. ? FormMode.Designing
  36. : FormMode.Preview;
  37. SwitchView.Content = value ? "Preview" : "Design";
  38. }
  39. }
  40. public event DynamicFormDesignGrid.CreateVariableHandler OnCreateVariable
  41. {
  42. add => Grid.OnCreateVariable += value;
  43. remove => Grid.OnCreateVariable -= value;
  44. }
  45. public event DynamicFormDesignGrid.EditVariableHandler OnEditVariable
  46. {
  47. add => Grid.OnEditVariable += value;
  48. remove => Grid.OnEditVariable -= value;
  49. }
  50. public string SaveLayout()
  51. {
  52. return Form.SaveLayout();
  53. }
  54. private void SwitchView_Click(object sender, RoutedEventArgs e)
  55. {
  56. Designing = !Designing;
  57. }
  58. private void OK_Click(object sender, RoutedEventArgs e)
  59. {
  60. DialogResult = true;
  61. }
  62. private void Cancel_Click(object sender, RoutedEventArgs e)
  63. {
  64. DialogResult = false;
  65. }
  66. private void DynamicFormWindow_KeyDown(object sender, KeyEventArgs e)
  67. {
  68. Grid.HandleKeyDown(e);
  69. }
  70. }
  71. }