GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GPALFormForm.cs
1// =============================================================================
2// GPAL - Generally Positive Automation Library
3// Copyright © 2026 Software Decisions, Inc. All rights reserved.
4//
5// This file is part of GPAL.
6// Licensed under the Business Source License 1.1
7//
8// Primary development, architecture, and vision by Michael B. Vederman,
9// CEO of Software Decisions, Inc., Texas.
10//
11// Internal development maintained privately.
12// Public releases appear on GitHub: https://github.com/SoftwareDecisionsInc/GPAL.
13//
14// See LICENSE for full terms, including Additional Use Grant.
15// =============================================================================
16
17using System;
18using System.Collections.Generic;
19using System.Drawing;
20using System.Linq;
21using System.Text;
22using System.Threading.Tasks;
23using System.Windows.Forms;
24using System.Windows.Forms.DataVisualization.Charting;
25using static GenerallyPositive.Enums;
27
29{
30 internal class GPALFormForm : System.Windows.Forms.Form
31 {
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; }
38
39 internal Size InitialSize { get; set; }
40
45 internal void SwitchToTab(GPALControl controlEntry)
46 {
47 Control control = (Control)controlEntry.WindowsControl;
48
49 while (null != control.Parent)
50 {
51 if (typeof(TabPage) == control.GetType())
52 ((TabControl)control.Parent).SelectedTab = (TabPage)control;
53 control = control.Parent;
54 }
55 }
56
57 protected override bool ProcessCmdKey(ref Message msg, System.Windows.Forms.Keys keyData)
58 {
59 foreach (GPALControl controlEntry in ControlList)
60 if (controlEntry.ShortCutKey == keyData)
61 {
62 SwitchToTab(controlEntry);
63 switch (controlEntry.ControlType)
64 {
65 case FormControlType.Button:
66 ((Button)controlEntry.WindowsControl).PerformClick();
67 break;
68 case FormControlType.Checkbox:
69 ((CheckBox)controlEntry.WindowsControl).Select();
70 break;
71 case FormControlType.ComboBox:
72 var comboBox = (ComboBox)controlEntry.WindowsControl;
73 comboBox.Focus();
74 comboBox.DroppedDown = true;
75 break;
76 case FormControlType.Label:
77 ((Label)controlEntry.WindowsControl).Select();
78 break;
79 case FormControlType.RadioButton:
80 ((RadioButton)controlEntry.WindowsControl).Select();
81 break;
82 case FormControlType.DateTimePicker:
83 ((DateTimePicker)controlEntry.WindowsControl).Focus();
84 break;
85 case FormControlType.NumericUpDown:
86 ((NumericUpDown)controlEntry.WindowsControl).Focus();
87 break;
88 case FormControlType.DataGridView:
89 ((DataGridView)controlEntry.WindowsControl).Focus();
90 break;
91 case FormControlType.ListView:
92 ((ListView)controlEntry.WindowsControl).Focus();
93 break;
94 case FormControlType.TreeView:
95 ((TreeView)controlEntry.WindowsControl).Focus();
96 break;
97 case FormControlType.Input:
98 case FormControlType.TextArea:
99 ((TextBox)controlEntry.WindowsControl).Focus();
100 break;
101 case FormControlType.Chart:
102 ((Chart)controlEntry.WindowsControl).Focus();
103 break;
104 case FormControlType.Tab:
105 ((TabPage)controlEntry.WindowsControl).Focus();
106 break;
107 }
108 return true;
109 }
110
111 return base.ProcessCmdKey(ref msg, keyData);
112 }
113
114 public override Size GetPreferredSize(Size proposedSize)
115 {
116 if (InitialSize.Width > 0 && InitialSize.Height > 0)
117 {
118 // Return the fluent-set size as preferred
119 return InitialSize;
120 }
121
122 // Fallback to default behavior if no explicit size was set
123 return base.GetPreferredSize(proposedSize);
124 }
125 }
126}
127
Form object that contains the fluent methods to create interactive forms. Instatiated using GPAL....
Definition GPALForm.cs:64