18using System.Collections.Generic;
22using System.Threading.Tasks;
23using System.Windows.Forms;
24using System.Windows.Forms.DataVisualization.Charting;
30 internal class GPALFormForm : System.Windows.Forms.Form
32 internal List<GPALControl> ControlList {
get;
set; } =
null;
33 internal string FormName {
get;
set; } =
null;
34 internal string FormTitle {
get;
set; } =
null;
35 internal GPALFile InputFile {
get;
set; }
36 internal GPALDatabase InputDatabase {
get;
set; }
37 internal CallAfterFillInDelegate CallAfterFillIn {
get;
set; }
39 internal Size InitialSize {
get;
set; }
45 internal void SwitchToTab(GPALControl controlEntry)
47 Control control = (Control)controlEntry.WindowsControl;
49 while (
null != control.Parent)
51 if (typeof(TabPage) == control.GetType())
52 ((TabControl)control.Parent).SelectedTab = (TabPage)control;
53 control = control.Parent;
57 protected override bool ProcessCmdKey(ref Message msg, System.Windows.Forms.Keys keyData)
59 foreach (GPALControl controlEntry
in ControlList)
60 if (controlEntry.ShortCutKey == keyData)
62 SwitchToTab(controlEntry);
63 switch (controlEntry.ControlType)
65 case FormControlType.Button:
66 ((Button)controlEntry.WindowsControl).PerformClick();
68 case FormControlType.Checkbox:
69 ((CheckBox)controlEntry.WindowsControl).Select();
71 case FormControlType.ComboBox:
72 var comboBox = (ComboBox)controlEntry.WindowsControl;
74 comboBox.DroppedDown =
true;
76 case FormControlType.Label:
77 ((Label)controlEntry.WindowsControl).Select();
79 case FormControlType.RadioButton:
80 ((RadioButton)controlEntry.WindowsControl).Select();
82 case FormControlType.DateTimePicker:
83 ((DateTimePicker)controlEntry.WindowsControl).Focus();
85 case FormControlType.NumericUpDown:
86 ((NumericUpDown)controlEntry.WindowsControl).Focus();
88 case FormControlType.DataGridView:
89 ((DataGridView)controlEntry.WindowsControl).Focus();
91 case FormControlType.ListView:
92 ((ListView)controlEntry.WindowsControl).Focus();
94 case FormControlType.TreeView:
95 ((TreeView)controlEntry.WindowsControl).Focus();
97 case FormControlType.Input:
98 case FormControlType.TextArea:
99 ((TextBox)controlEntry.WindowsControl).Focus();
101 case FormControlType.Chart:
102 ((Chart)controlEntry.WindowsControl).Focus();
104 case FormControlType.Tab:
105 ((TabPage)controlEntry.WindowsControl).Focus();
111 return base.ProcessCmdKey(ref msg, keyData);
114 public override Size GetPreferredSize(Size proposedSize)
116 if (InitialSize.Width > 0 && InitialSize.Height > 0)
123 return base.GetPreferredSize(proposedSize);