Class GPALControl
Base class for all GPAL form controls
Inheritance
Inherited Members
Namespace: GenerallyPositive.GPALForm
Assembly: GPAL.dll
Syntax
public class GPALControl : IAllowControlSettingsAndFontSettings, IAllowControlSettings, IAllowFontSettings
Properties
AutoSize
Autosize setting currently in use
Declaration
public bool AutoSize { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean | Autosize setting currently in use |
ControlAlignment
Declaration
public ContentAlignment ControlAlignment { get; }
Property Value
| Type | Description |
|---|---|
| System.Drawing.ContentAlignment |
ControlType
The control type of WindowsControl. Set when the control is instantiated with GPAL.
Declaration
public Enums.FormControlType ControlType { get; }
Property Value
| Type | Description |
|---|---|
| Enums.FormControlType |
FontType
The font currently being used
Declaration
public Font FontType { get; }
Property Value
| Type | Description |
|---|---|
| System.Drawing.Font | The font currently in use |
Name
Control name, only used for Information and Exception channel messages.
NOTE: Use .WithName fluent interface to set the control name.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Tag
for attaching value-added objects to carry along on form controls
Declaration
public object Tag { get; }
Property Value
| Type | Description |
|---|---|
| System.Object |
Text
For text based controls, get the text in the control.
NOTE: Use .WithText fluent interface to set text.
Declaration
public string Text { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
TextAlignment
The alignment currently in use
Declaration
public ContentAlignment TextAlignment { get; }
Property Value
| Type | Description |
|---|---|
| System.Drawing.ContentAlignment | The alignment currently being used |
WindowsControl
Underlying Windows form control, Button, Checkbox, Textbox, etc.
NOTE: Use GPAL to instantiate form controls.
Declaration
public dynamic WindowsControl { get; }
Property Value
| Type | Description |
|---|---|
| System.Object |
Methods
ToGPALObject()
Return a typeof(GPALControl) so that controls do not have to be cast.
Declaration
public dynamic ToGPALObject()
Returns
| Type | Description |
|---|---|
| System.Object | A GPALForm control object, whatever control was created via GPAL. |
Examples
static GPALTextArea gPALTextArea = GPAL.TextArea
.WithText("Type something here")
.WithCallback(InputHandler)
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.T)
.ToGPALObject();
static GPALLabel gPALLabel = GPAL.Label
.WithText("Form Tester")
.ToGPALObject();
static GPALCheckbox gPALCheckbox1 = GPAL.Checkbox
.WithChecked(true)
.WithText("Wait on document.ready")
.ToGPALObject();
WithAlignment(ContentAlignment)
Declaration
public IAllowControlSettings WithAlignment(ContentAlignment alignment)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.ContentAlignment | alignment |
Returns
| Type | Description |
|---|---|
| IAllowControlSettings |
WithAutoSize(Boolean)
Whether or not the label contents autosize to fit the label.
Declaration
public IAllowControlSettingsAndFontSettings WithAutoSize(bool autoSize)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | autoSize | True [default] to autosize. |
Returns
| Type | Description |
|---|---|
| IAllowControlSettingsAndFontSettings | Fluent interface to define more settings |
WithCallback(EventHandler)
Sets an eventhandler to attach to the Windows form control event.
See the GPAL controls for which event that is.
Declaration
public IAllowControlSettings WithCallback(EventHandler Callback)
Parameters
| Type | Name | Description |
|---|---|---|
| System.EventHandler | Callback | Your eventhandler specific for the control type |
Returns
| Type | Description |
|---|---|
| IAllowControlSettings | Fluent interface to define your control |
Examples
static GPALButton gPalButton3 = (GPALButton)GPAL.Button
.WithName("Exit")
.WithText("Exit")
.WithCallback(Button3ClickHandler)
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.E);
WithFont(Font)
The font style and size for the label display.
Declaration
public IAllowControlSettingsAndFontSettings WithFont(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Font | font | Default is ("Georgia", 16) |
Returns
| Type | Description |
|---|---|
| IAllowControlSettingsAndFontSettings | Fluent interface to define more settings |
WithName(String)
Sets the name for the control. Used in Information and Exception channel messages.
Declaration
public IAllowControlSettings WithName(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of your control |
Returns
| Type | Description |
|---|---|
| IAllowControlSettings | Fluent interface to define your control |
Examples
static GPALButton gPalButton3 = (GPALButton)GPAL.Button
.WithName("Exit")
.WithText("Exit")
.WithCallback(Button3ClickHandler)
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.E);
WithShortcutKey(Keys)
Set the keyboard shortcut that will activate this controls eventhandler defined with .WithCallback
Declaration
public IAllowControlSettings WithShortcutKey(Keys shortCutKey)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Windows.Forms.Keys | shortCutKey | The shortcut key |
Returns
| Type | Description |
|---|---|
| IAllowControlSettings | Fluent interface to define your control |
Examples
static GPALButton gPalButton3 = (GPALButton)GPAL.Button
.WithName("Exit")
.WithText("Exit")
.WithCallback(Button3ClickHandler)
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.E);
WithTag(Object)
Set the text of the control.
Declaration
public IAllowControlSettings WithTag(object tag)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | tag | Text to display in the control. |
Returns
| Type | Description |
|---|---|
| IAllowControlSettings | Fluent interface to define your control |
Examples
static GPALButton gPalButton3 = (GPALButton)GPAL.Button
.WithName("Exit")
.WithText("Exit")
.WithTag(someObject)
.WithCallback(Button3ClickHandler) // can then use tag to get extra values for operation upon click
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.E);
WithText(String)
Set the text of the control.
Declaration
public IAllowControlSettingsAndFontSettings WithText(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | text | Text to display in the control. |
Returns
| Type | Description |
|---|---|
| IAllowControlSettingsAndFontSettings | Fluent interface to define your control |
Examples
static GPALButton gPalButton3 = (GPALButton)GPAL.Button
.WithName("Exit")
.WithText("Exit")
.WithCallback(Button3ClickHandler)
.WithShortcutKey(System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.E);
WithTextAlignment(ContentAlignment)
The alignment of the text inside the label.
Declaration
public IAllowControlSettingsAndFontSettings WithTextAlignment(ContentAlignment textAlignment)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.ContentAlignment | textAlignment |
Returns
| Type | Description |
|---|---|
| IAllowControlSettingsAndFontSettings | Fluent interface to define more settings |