GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
Interfaces.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 OpenQA.Selenium;
26using static GenerallyPositive.Enums;
27using static GenerallyPositive.GPAL;
28using System.Windows.Forms.DataVisualization.Charting;
29using System.Windows.Forms;
30using System.Data;
31
33{
34 #region <FormInterfaces>
35 public interface IAllowDefault
36 {
37 IAllowControlSettingsAndDefault Default { [Forms(Description = "Fluent interface to designate this button as the default button")] get; }
38 }
39 public interface IAllowFillInFrom
40 {
41 [Data(Description = "Fill in (overwrite) the forms inputs using tokens derived from the file")]
42 IAllowFormSettingsAndActions FillInFrom(GPALFile inputFile);
43 [Data(Description = "Append to the end of the forms inputs using tokens derived from the file")]
44 IAllowFormSettingsAndActions AppendFrom(GPALFile inputFile);
45 [Data(Description = "Insert at the beginning of the forms inputs using tokens derived from the file")]
46 IAllowFormSettingsAndActions InsertFrom(GPALFile inputFile);
47
48 [Data(Description = "Fill in (overwrite) the forms inputs using tokens derived from the database")]
49 IAllowFormSettingsAndActions FillInFrom(GPALDatabase inputDatabase);
50 [Data(Description = "Append to the end of the forms inputs using tokens derived from the database")]
51 IAllowFormSettingsAndActions AppendFrom(GPALDatabase inputDatabase);
52 [Data(Description = "Insert at the beginning of the forms inputs using tokens derived from the database")]
53 IAllowFormSettingsAndActions InsertFrom(GPALDatabase inputDatabase);
54
55 [Data(Description = "Fill in (overwrite) the forms inputs using tokens derived from the GPALGrid")]
56 IAllowFormSettingsAndActions FillInFrom(IGPALGrid<string> inputGrid);
57 [Data(Description = "Append to the end of the forms inputs using tokens derived from the GPALGrid")]
58 IAllowFormSettingsAndActions AppendFrom(IGPALGrid<string> inputGrid);
59 [Data(Description = "Insert at the beginning of the forms inputs using tokens derived from the GPALGrid")]
60 IAllowFormSettingsAndActions InsertFrom(IGPALGrid<string> inputGrid);
61 }
62 public interface IAllowChartSettings
63 {
64 [Settings(Description = "Sets the series to plot in the chart")]
65 IAllowControlSettingsAndChartSettings WithSeries(Series series);
66 [Settings(Description = "Set the color palette of the chart bars")]
67 IAllowControlSettingsAndChartSettings WithPalette(ChartColorPalette colorPalette);
68 [Settings(Description = "The title to display at the top of the chart")]
69 IAllowControlSettingsAndChartSettings WithTitle(string title);
70 }
71 public interface IAllowFontSettings
72 {
73 [Settings(Description = "The font style and size for the label display")]
74 IAllowControlSettingsAndFontSettings WithFont(Font font);
75 [Settings(Description = "The alignment of the text inside the label")]
76 IAllowControlSettingsAndFontSettings WithTextAlignment(ContentAlignment contentAlignment);
77 [Settings(Description = "Whether or not the label contents autosize to fit the label")]
78 IAllowControlSettingsAndFontSettings WithAutoSize(bool autoSize);
79 }
80 public interface IAllowControlSettings
81 {
82 [Callback(Description = "Sets an eventhandler to attach to the Windows form control event")]
83 IAllowForEventControlSettings WithCallback<TDelegate>(TDelegate handler)
84 where TDelegate : Delegate;
85 [Settings(Description = "Attach a handler that runs off the UI thread, so the form keeps painting while it works. GPAL controls set from it marshal back on their own.")]
86 IAllowForEventControlSettings WithCallbackOffUIThread<TDelegate>(TDelegate handler)
87 where TDelegate : Delegate;
88 [Settings(Description = "Sets the height of the control, in pixels")]
89 IAllowControlSettings WithHeight(int height);
90 [Settings(Description = "The width of the control in pixels. Without one the control stretches across its container; with one it keeps that width and sits centered")]
91 IAllowControlSettings WithWidth(int width);
92 [Settings(Description = "Sets the name for the control")]
93 IAllowControlSettings WithName(string name);
94 [Settings(Description = "Set the text of the control")]
95 IAllowControlSettings WithTag(object tag);
96 [Settings(Description = "Whether the control responds to the user. Every control has it")]
97 IAllowControlSettings WithEnabled(bool trueFalse = true);
98 [Settings(Description = "Whether the user can change what the control holds. The controls that hold nothing ignore it")]
99 IAllowControlSettings WithReadOnly(bool readOnly = true);
101 //IAllowControlSettings WithAlignment(ContentAlignment alignment);
102 [Settings(Description = "Set the text of the control")]
103 IAllowControlSettingsAndFontSettings WithText(string textToUse);
104 [Settings(Description = "Set the keyboard shortcut that will activate this controls eventhandler defined with.WithCallback")]
105 IAllowControlSettings WithShortcutKey(System.Windows.Forms.Keys shortCutKey);
106 [Settings(Description = "Sets the tooltip text shown when hovering over the control")]
107 IAllowToolTipDelay WithToolTip(string toolTipText);
108 dynamic ToGPALObject();
109 }
111 {
112 [Callback(Description = "Specifies which event the most recently added WithCallback handler should be attached to, replacing its")]
113 IAllowControlSettings ForEvent(ControlEventType eventType);
114 }
116 {
117 [Settings(Description = "Sets the title bar text of the selection dialog")]
118 IAllowFileSelectorControlSettings WithTitle(string title);
119 [Settings(Description = "Sets the directory the selection dialog initially opens to")]
120 IAllowFileSelectorControlSettings WithInitialDirectory(string path);
121 [Settings(Description = "Sets the file type filter used by the OpenFileDialog when WithSelectFolder is false")]
122 IAllowFileSelectorControlSettings WithFilter(string filter);
123 [Settings(Description = "Sets whether the control opens a FolderBrowserDialog (folder selection) or an OpenFileDialog (file selection)")]
124 IAllowFileSelectorControlSettings WithSelectFolder(bool folderMode);
125 [Settings(Description = "Sets whether the file dialog allows selecting multiple files")]
126 IAllowFileSelectorControlSettings WithMultiSelect(bool allowMulti);
127 [Settings(Description = "Show an editable path box with a small browse button, so a path can be typed or picked")]
128 IAllowFileSelectorControlSettings WithCompact(bool compact);
129 [Settings(Description = "Sets placeholder hint text shown in the text field when it is empty")]
130 IAllowFileSelectorControlSettings WithPlaceholder(string placeholder);
131 [Settings(Description = "The path the selector starts on")]
132 IAllowFileSelectorControlSettings WithSelectedPath(string path);
133 }
135 {
136 [Forms(Description = "A vertical bar with a left and a right pane, the left one this share of the width, so it keeps its proportion as the form resizes")]
137 IAllowSplitterControlSettings HSplit(int leftWidth);
138 [Forms(Description = "A vertical bar with a left and a right pane, the left one this share of the width, so it keeps its proportion as the form resizes")]
139 IAllowSplitterControlSettings HSplit(double leftPercent);
140 [Forms(Description = "A horizontal bar with a top and a bottom pane, the top one this many pixels tall")]
141 IAllowSplitterControlSettings VSplit(int topHeight);
142 [Forms(Description = "A horizontal bar with a top and a bottom pane, the top one this share of the height, so it keeps its proportion as the form resizes")]
143 IAllowSplitterControlSettings VSplit(double topPercent);
144 [Settings(Description = "Add a control to the splitter")]
145 IAllowSplitterControlSettings WithFormControl(object gPALFormControl);
146 // the base one hands back IAllowControlSettings, which has neither the panes nor a typed ToGPALObject, so
147 // a splitter given a height would come out of the chain as dynamic and only fail once the form is built
148 [Settings(Description = "A vertical bar with a left and a right pane, the left one this many pixels wide")]
149 new IAllowSplitterControlSettings WithHeight(int height);
150 new GPALSplitter ToGPALObject();
151 }
153 {
154 [Settings(Description = "The caption along the top of the box")]
155 new IAllowGroupBoxControlSettings WithText(string text);
156 [Settings(Description = "Add a control inside the box")]
157 IAllowGroupBoxControlSettings WithFormControl(object gPALFormControl);
158 new GPALGroupBox ToGPALObject();
159 }
161 {
162 [Settings(Description = "Sets whether checkboxes are displayed next to each tree node")]
163 IAllowTreeViewControlSettings WithCheckBoxes(bool enable);
164 [Settings(Description = "Sets whether lines are drawn between sibling nodes and their parent")]
165 IAllowTreeViewControlSettings WithShowLines(bool show);
166 [Settings(Description = "Sets whether plus/minus expand buttons are displayed next to nodes that have children")]
167 IAllowTreeViewControlSettings WithShowPlusMinus(bool show);
168 }
170 {
171 [Settings(Description = "Sets the initial date/time value")]
172 IAllowDateTimePickerControlSettings WithValue(DateTime value);
173 [Settings(Description = "Sets the display format")]
174 IAllowDateTimePickerControlSettings WithFormat(DateTimePickerFormat format);
175 [Settings(Description = "Sets a custom display format string, used when Format is Custom")]
176 IAllowDateTimePickerControlSettings WithCustomFormat(string formatString);
177 }
179 {
180 [Settings(Description = "Sets the initial value")]
181 IAllowNumericUpDownControlSettings WithValue(decimal value);
182 [Settings(Description = "Sets the minimum allowed value")]
183 IAllowNumericUpDownControlSettings WithMinimum(decimal min);
184 [Settings(Description = "Sets the maximum allowed value")]
185 IAllowNumericUpDownControlSettings WithMaximum(decimal max);
186 [Settings(Description = "Sets the amount the value changes when the up/down spinner is clicked")]
187 IAllowNumericUpDownControlSettings WithIncrement(decimal inc);
188 [Settings(Description = "Sets how many decimal places are displayed")]
189 IAllowNumericUpDownControlSettings WithDecimalPlaces(int places);
190 }
192 {
193 [Settings(Description = "The column headers of the list")]
194 IAllowListViewControlSettings WithColumns(params string[] headers);
195 [Settings(Description = "Sets the column headers for the list view (used in Details mode)")]
196 IAllowListViewControlSettings WithCheckBoxes(bool enable = true);
197 [Settings(Description = "Sets how items are displayed (Details, List, LargeIcon, SmallIcon, or Tile)")]
198 IAllowListViewControlSettings WithView(ListViewMode view);
199 [Settings(Description = "Sets whether selecting an item highlights the entire row")]
200 IAllowListViewControlSettings WithFullRowSelect(bool enable);
201 [Settings(Description = "Sets whether multiple items can be selected at once")]
202 IAllowListViewControlSettings WithMultiSelect(bool enable);
203 [Settings(Description = "How wide each column is, in column order and in pixels. -1 fits the widest item and -2 the wider of that and the header, both re-fit as rows are added or cleared. The last column takes any width the others leave, never narrower than what it was asked for")]
204 IAllowListViewControlSettings WithColumnWidth(params int[] widths);
205 [Settings(Description = "What share of the width each column takes, in column order. Shares reflow as the form is resized")]
206 IAllowListViewControlSettings WithColumnWidth(params double[] shares);
207 [Settings(Description = "How much of the spare width the next column takes when the list resizes")]
208 IAllowListViewControlSettings WithColumnWeight(double weight);
209 [Settings(Description = "Whether clicking a column header sorts the list by it")]
210 IAllowListViewControlSettings WithSortable(bool sortable = true);
211 }
213 {
214 [Settings(Description = "Sets the initial status text")]
215 new IAllowStatusStripControlSettings WithText(string text);
216 }
218 {
219 [Settings(Description = "Opens (or reselects) a top-level menu")]
220 IAllowMenuBarControlSettings WithMenu(string topMenu);
221 [Settings(Description = "Adds an item to the currently open top-level menu")]
223 [Settings(Description = "Adds a separator line to the currently open top-level menu")]
224 IAllowMenuBarControlSettings WithSeparator();
225 }
227 {
228 [Settings(Description = "Adds a button to the toolbar")]
230 [Settings(Description = "Adds a vertical separator between toolbar buttons")]
231 IAllowToolbarControlSettings WithSeparator();
232 }
234 {
235 [Settings(Description = "Sets the item's display text")]
236 new IAllowBarItemSettings WithText(string text);
237 // declared again here so it answers with a bar item rather than the settings every control shares,
238 // which is what keeps the rest of a bar item's own chain reachable after it
239 [Settings(Description = "Greys the item and stops it being clicked")]
240 new IAllowBarItemSettings WithEnabled(bool trueFalse = true);
241 [Settings(Description = "Sets the item's icon from an in-memory image")]
242 IAllowBarItemSettings WithImage(Image image);
243 [Settings(Description = "Sets the item's icon by loading it from the file referenced by a GPALFile")]
244 IAllowBarItemSettings WithImage(GPALFile file);
245 }
247 {
248 [Settings(Description = "Sets the initial Markdown source text")]
249 new IAllowRichTextBoxControlSettings WithText(string text);
250 }
252 {
253 [Settings(Description = "Appends the given items to the dropdown list, in order")]
254 IAllowComboBoxControlSettings WithItems(params string[] itemArray);
255 [Settings(Description = "Appends the given items to the dropdown list, in order")]
256 IAllowComboBoxControlSettings WithItems(IEnumerable<string> itemCollection);
257 [Settings(Description = "Appends the items from a non-generic array (e.g. the result of GetValues) to the dropdown list, converting each element to its string representation")]
258 IAllowComboBoxControlSettings WithItems(Array itemArray);
259 [Settings(Description = "Sets which item is initially selected, by index")]
260 IAllowComboBoxControlSettings WithSelectedIndex(int index);
261 [Settings(Description = "Sets which item is initially selected, by its display text")]
262 IAllowComboBoxControlSettings WithSelectedItem(string name);
263 }
265 {
266 [Settings(Description = "Sets the column header names for the grid")]
267 IAllowDataGridViewControlSettings WithColumns(params string[] columnNames);
268 [Settings(Description = "Sets whether the grid's cells are read-only")]
269 new IAllowDataGridViewControlSettings WithReadOnly(bool readOnly = true);
270 [Settings(Description = "Sets whether columns should be auto-generated (named 'Column 1', 'Column 2', etc.) when no column names were provided via WithColumns")]
271 IAllowDataGridViewControlSettings WithAutoGenerateColumns(bool autoGenerate);
272 [Settings(Description = "How wide each column is, in column order and in pixels. A width that is not positive is ignored and the column is left as the grid sizes it. The last column takes any width the others leave, never narrower than what it was asked for")]
273 IAllowDataGridViewControlSettings WithColumnWidth(params int[] widths);
274 [Settings(Description = "What share of the width each column takes, in column order. Shares reflow as the form is resized")]
275 IAllowDataGridViewControlSettings WithColumnWidth(params double[] shares);
276 [Settings(Description = "Which columns wrap their text, in column order. Said bare, every column wraps. Rows grow to hold what wrapped")]
277 IAllowDataGridViewControlSettings WithWrap(params bool[] wrap);
278 [Settings(Description = "The rows to show, as a grid")]
279 IAllowDataGridViewControlSettings WithInput(IGPALGrid<string> grid);
280 [Settings(Description = "The rows to show, as a DataTable. Its columns name the grid's columns")]
281 IAllowDataGridViewControlSettings WithInput(DataTable dataTable);
282 [Settings(Description = "The rows to show, read by running the database's query. Its columns name the grid's columns")]
284 [Settings(Description = "The rows to show, read from a file and split the way the file says")]
286 [Settings(Description = "The first row a range covers, counting from one. Unset reads from the top")]
287 IAllowDataGridViewControlSettings WithStartRow(int row);
288 [Settings(Description = "The first column a range covers, counting from one. Unset reads from the left")]
289 IAllowDataGridViewControlSettings WithStartColumn(int column);
290 [Settings(Description = "The last row a range covers, counting from one. Unset reads to the bottom")]
291 IAllowDataGridViewControlSettings WithEndRow(int row);
292 [Settings(Description = "The last column a range covers, counting from one. Unset reads to the right")]
293 IAllowDataGridViewControlSettings WithEndColumn(int column);
294 [Action(Description = "Read what the grid is showing, or the range of it named by the start and end settings")]
295 IAllowDataGridViewControlSettings GetGrid(out IGPALGrid<string> grid);
296 }
298 {
299 [Settings(Description = "The image to display, read from a file.")]
301 [Settings(Description = "The image to display.")]
302 IAllowPictureControlSettings WithImage(System.Drawing.Image image);
303 [Settings(Description = "How the image fits the control. Zoom by default, which scales it to fit and keeps its shape.")]
304 IAllowPictureControlSettings WithSizeMode(PictureBoxSizeMode sizeMode);
305 }
307 {
308 [Settings(Description = "The lowest value the slider can be dragged to.")]
309 IAllowSliderControlSettings WithMinimum(int min);
310 [Settings(Description = "The highest value the slider can be dragged to.")]
311 IAllowSliderControlSettings WithMaximum(int max);
312 [Settings(Description = "Where the slider starts.")]
313 IAllowSliderControlSettings WithValue(int value);
314 [Settings(Description = "How far apart the tick marks are.")]
315 IAllowSliderControlSettings WithTickFrequency(int tickFrequency);
316 [Settings(Description = "Horizontal or vertical.")]
317 IAllowSliderControlSettings WithOrientation(Orientation orientation);
318 }
320 {
321 [Settings(Description = "Sets the initial progress value, clamped to Minimum/Maximum, and syncs it to the underlying control")]
322 IAllowProgressBarControlSettings WithValue(int value);
323 [Settings(Description = "Sets the minimum progress value")]
324 IAllowProgressBarControlSettings WithMinimum(int min);
325 [Settings(Description = "Sets the maximum progress value")]
326 IAllowProgressBarControlSettings WithMaximum(int max);
327 [Settings(Description = "Sets the visual style of the progress bar (e.g. continuous, blocks, marquee)")]
328 IAllowProgressBarControlSettings WithStyle(ProgressBarStyle style);
329 }
331 {
332 IAllowControlSettingsAndTableLayoutPanelSettings WithGrowStyle(TableLayoutPanelGrowStyle tableLayoutPanelGrowStyle);
333 IAllowControlSettingsAndTableLayoutPanelSettings WithColumnCount(int columnCount);
334 IAllowControlSettingsAndTableLayoutPanelSettings WithRowCount(int rowCount);
335 }
336 public interface IAllowCallBack
337 {
338 // return values
339 // 0 = not handled
340 // 1 = handled
341 // -1 = error
342 // IAllowAfterAnySelector CallIfFound(Form.CallIfDelegate callIfFound);
343 // IAllowAfterAnySelector CallIfNotFound(Form.CallIfDelegate callIfNotFound);
344 [Callback(Description = "Add a handler to call after a row of tokens is consumed and after all inputs are filled in with data")]
345 IAllowFormSettingsAndActions CallAfterFillIn(GPALForm.CallAfterFillInDelegate callAfterFillIn);
346 }
347 public interface IAllowFormActions
348 {
349 [Action(Description = "Show the GPAL form so it may be automated by tokens")]
351 [Action(Description = "Show the GPAL form as a modal")]
352 IAllowFormActions ShowDialog();
353 [Action(Description = "Hide the form. If ShowDialog is the last call in Main, hiding it from a button ends the program")]
354 IAllowFormActions Hide();
355 dynamic ToGPALObject();
356 }
358 {
359 [Settings(Description = "Sets how long the tooltip set via WithToolTip remains visible")]
360 IAllowControlSettings WithToolTipDelay(int delayInMs);
361 }
366
367 public interface IAllowFormSettings
368 {
369 [Settings(Description = "Add a control to the form. Containers are built whole first, so a splitter or a group box is added the same way as anything else")]
370 IAllowFormSettingsAndActions WithFormControl(GPALControl gPALFormControl);
371 [Settings(Description = "Define the initial width of your GPAL form")]
372 IAllowFormSettingsAndActions WithWidth(int width);
373 [Settings(Description = "The width every button on the form takes, in pixels, unless the button asked for its own. A button with a width keeps it and sits centered instead of stretching")]
374 IAllowFormSettingsAndActions WithButtonWidth(int width);
375 [Settings(Description = "Define the initial height of your GPAL form")]
376 IAllowFormSettingsAndActions WithHeight(int height);
377 [Settings(Description = "Define the initial coordinate of the top side of your GPAL form")]
378 IAllowFormSettingsAndActions WithTop(int top);
379 [Settings(Description = "Define the initial coordinate of the left side of your GPAL form")]
380 IAllowFormSettingsAndActions WithLeft(int left);
381 [Settings(Description = "The title to display at the top of your form")]
382 IAllowFormSettingsAndActions WithTitle(string title);
383 }
394 {
395 [Settings(Description = "Grey hint text shown while the box is empty")]
396 IAllowControlSettingsAndPlaceholder WithPlaceholder(string placeholderText);
397 }
404 {
405 [Settings(Description = "Grey hint text shown while the box is empty")]
406 IAllowControlSettingsPlaceholderAndPassword WithPlaceholder(string placeholderText);
407 IAllowControlSettingsPlaceholderAndPassword IsPassword { [Settings(Description = "Hide what is typed, for a password")] get; }
408 }
411 {
412 [Settings(Description = "The address the link opens in the default browser. Without one, the link opens its own text when that is an address")]
413 IAllowControlSettingsAndUrl WithUrl(string url);
414 }
417 {
418 [Settings(Description = "Sets whether the checkbox is checked")]
419 IAllowControlSettingsAndChecked WithChecked(bool trueFalse = false);
420 }
430 #endregion <FormInterfaces>
431 #region <Atoms>
432 // what a control can be told that every control cannot is declared on that control's own settings
433 // interface and answers with it, so the settings a control has stay reachable from each other
434 #endregion
435}
436
Class to define database usage. Currently only used for input from a table, sql or stored procedure....
GPAL File object instantied with GPAL.File Used to load tokens into a GPALGrid [rows/columns].
Definition GPALFile.cs:36
A single item shared by GPAL menu bars and toolbars. Because it derives from GPALControl it speaks th...
Base class for all GPAL form controls.
Form object that contains the fluent methods to create interactive forms. Instatiated using GPAL....
Definition GPALForm.cs:64
delegate CallIfStatus CallAfterFillInDelegate(GPALForm myForm, IGPALGrid< string > tokens, int tokenIdx)
Delegate callback for the CallAfterFillIn EventHandler which will be invoked after each row of tokens...
A titled box around a set of controls, instantiated with GPAL.GroupBox and laid out like any other co...
Two panes with a bar between them, instantiated with GPAL.Splitter and laid out like any other contro...
Everything starts here, all the GPAL controls and global settings using fluent syntax are here....
Definition GPAL.cs:49