PSEC - Powershell Enhanced Capability
Version 1.2.1

Form Class extends Area (src: gui-classes.psm1)

Extended By

WflForm Dialog

Description

Implementation of Windows.Forms.Form.

Details

The form is the global object used to hang things off of since every Elem has a pointer to the form.

It is extended to add custom objects. See x.


Public Fields

FieldFormatDescription
$appGbl[hashtable] application wide globals such as base folder
$appJob[object] Owning Object (such as JobDesc) or $null
$appRoot[object] app specific root object
$bDebLayout[boolean] on if layout debug
$bNoJam[boolean] EC9B30 - resize exit. Do not ajust form size
$bRestartGUI[boolean] EC2520 - on if to restart GUI after closing
$cfg[hashtable] Related config
$colors[hashtable] Registered RBG colors
$confirmClose[ScriptBlock] Script to execute before closing. return true to close, false to cancel close.
$ctx[object] context for confirmClose
$custObj[object] Custon owning object
$dialogs[hashtable] Dialogs attached to Form
$elems[hashtable] Elems contained in form
$exitCharSeq[string] if we used k/b to exit, set flags. as below
$exitCmdSeq[string] Actual exit str (copy of $exitCharStr, timing issue means above is not reliable)
$exitExitSeq[string] What we look for. Default .. Exit GUI.
$exitRestartSeq[string] What we look for. Default // Restart GUI and classes with exit code 901
$fonts[hashtable] Registered named fonts
$gridList[object] Registered Grids
$icons[hashtable] Registered named Icons
$layoutExit[scriptBlock] execute after layout performed
$layoutExitBusy[boolean] prevents recursion if exit dinks with sizes and causes new
$onClose[scriptBlock] Script to execute on closing
$openExit[scriptBlock] EC2701 - used to perform processing after form is visible
$resizeExit[scriptBlock] EC9B29 - resize exit
$title[string] Value shown in outer window caption
$toolTip[Windows.Forms.ToolTip] Tool tips attached to Form

Method Index

addGridList Register a Grid on the Form

staticcreateForm not-described

findColor Find a color by name. Used internally by backColor and foreColor methods.

findElem Find the registered Elem using the $name parameter as the search argument

findElemOpt Find the registered Elem using the $name parameter as the search argument

getBoldFont Create a bolded font of the specified Points using the font family \"Microsoft Sans Serif\"

getBoldFont Create a bolded font of the specfied Points using the specified font family

getFixedFont Create a fixed-font of the specified Points using the font family \"Lucida Console\"

getFont Create a font of the specified Points using the font family \"Microsoft Sans Serif\"

getFont Create a font of the specfied Points using the specified font family

log Log a message to the Logger window of the form, if it exists

log Log a black message to the Logger window of the form, if it exists

logFlag Log a red message to the Logger window of the form, if it exists

logGood Log a green message to the Logger window of the form, if it exists

logWarn Log an orange message to the Logger window of the form, if it exists

regColor Register a color by name

regDialog Register a Dialog as being open

regElem Register Elem using the Elem.name property

regElem Register Elem using the $name parameter as the name

regFont Register a font by name

regIcon Register an Icon (image) by name

remDialog Remove a Dialog for the registry

resize Resizes the current window

rgb Calculate the color value using RGB values

setConfirmClose Sets or removes confirmClose property

showForm shows the form


addGridList Method index (src: gui-classes.psm1)

Signature

[void] addGridList ( [Windows.Forms.DataGridView]$dgv)

Parameters

Parameter Format Description

$dgv Windows.Forms.DataGridView subject DataGridView

Description

Register a Grid on the Form

Details

Timing issues exist with Grids and focus. Registering the Grid allows for race conditions to be circumvented and the 'non-focus' of a grid cell to be more reliable.


createForm Method index (src: gui-classes.psm1)

Signature

static [Form] createForm ( [object]$appJob, [hashtable]$cfg, [scriptBlock]$closeCallBack, [Form]$form)

Parameters

Parameter Format Description

$appJob object parm description missing

$cfg hashtable Loaded config file

$closeCallBack scriptBlock parm description missing

$form Form parm description missing

Details

The ?@Form@? created is the topmost window of the GUI interface

The optional $cfg parm provides a hashtable where configration information such as window sizes is stored. This is used in rebuilding the window. See ?@formCfg@?.

The optional $closeCallBack parm provides a script or function that is called when the window is about to close. See ?@formClose@?.

The optional $form parm provides a means whereby a Form can be extendeds with additional fields or behavoirs. see ?@formExtend@?.

.optp $cfg Configuration file .optp $closeCallBack Function/script to call when ?@Form@? closes .optp $Form Existing extended ?@Form@? to use as parent


findColor Method index (src: gui-classes.psm1)

Signature

[string] findColor ( [string]$name)

Parameters

Parameter Format Description

$name string name to lookup

Description

Find a color by name. Used internally by backColor and foreColor methods.


findElem Method index (src: gui-classes.psm1)

Signature

[Elem] findElem ( [string]$name)

Parameters

Parameter Format Description

$name string name to lookup

Description

Find the registered Elem using the $name parameter as the search argument

Details

Throws an error if not found


findElemOpt Method index (src: gui-classes.psm1)

Signature

[Elem] findElemOpt ( [string]$name)

Parameters

Parameter Format Description

$name string name to lookup

Description

Find the registered Elem using the $name parameter as the search argument

Details

Returns $null if not found


getBoldFont Method index (src: gui-classes.psm1)

Signature

[System.Drawing.Font] getBoldFont ( [int]$pts)

Parameters

Parameter Format Description

$pts int Points size of font

Description

Create a bolded font of the specified Points using the font family "Microsoft Sans Serif"


getBoldFont Method index (src: gui-classes.psm1)

Signature

[System.Drawing.Font] getBoldFont ( [int]$pts, [string]$family)

Parameters

Parameter Format Description

$pts int Points size of font

$family string Font family to use

Description

Create a bolded font of the specfied Points using the specified font family


getFixedFont Method index (src: gui-classes.psm1)

Signature

[System.Drawing.Font] getFixedFont ( [int]$pts)

Parameters

Parameter Format Description

$pts int Points size of font

Description

Create a fixed-font of the specified Points using the font family "Lucida Console"


getFont Method index (src: gui-classes.psm1)

Signature

[System.Drawing.Font] getFont ( [int]$pts)

Parameters

Parameter Format Description

$pts int Points size of font

Description

Create a font of the specified Points using the font family "Microsoft Sans Serif"


getFont Method index (src: gui-classes.psm1)

Signature

[System.Drawing.Font] getFont ( [int]$pts, [string]$family)

Parameters

Parameter Format Description

$pts int Points size of font

$family string Font family to use

Description

Create a font of the specfied Points using the specified font family


log Method index (src: gui-classes.psm1)

Signature

[void] log ( [string]$msg, [string]$col)

Parameters

Parameter Format Description

$msg string the message

$col string the color (default black)

Description

Log a message to the Logger window of the form, if it exists

Notes

The specified color sometimes has difficulty 'taking', especially in the early stages of the windows creation or after clearing the logging window using the "Clear Log" link


log Method index (src: gui-classes.psm1)

Signature

[void] log ( [string]$msg)

Parameters

Parameter Format Description

$msg string parm description missing

Description

Log a black message to the Logger window of the form, if it exists


logFlag Method index (src: gui-classes.psm1)

Signature

[void] logFlag ( [string]$msg)

Parameters

Parameter Format Description

$msg string parm description missing

Description

Log a red message to the Logger window of the form, if it exists


logGood Method index (src: gui-classes.psm1)

Signature

[void] logGood ( [string]$msg)

Parameters

Parameter Format Description

$msg string parm description missing

Description

Log a green message to the Logger window of the form, if it exists


logWarn Method index (src: gui-classes.psm1)

Signature

[void] logWarn ( [string]$msg)

Parameters

Parameter Format Description

$msg string parm description missing

Description

Log an orange message to the Logger window of the form, if it exists


regColor Method index (src: gui-classes.psm1)

Signature

[void] regColor ( [string]$name, [int]$r, [int]$g, [int]$b)

Parameters

Parameter Format Description

$name string the name to register under

$r int red component of RGB value

$g int green component of RGB value

$b int blue component of RGB value

Description

Register a color by name


regDialog Method index (src: gui-classes.psm1)

Signature

[void] regDialog ( [Dialog]$dlg)

Parameters

Parameter Format Description

$dlg Dialog parm description missing

Description

Register a Dialog as being open

Details

This is used so that open dialogs are automatically closed when the parent window is closed. Failure to do this causes orphan windows that tangles up the Windows OS.

This is automatically called by the Dialog create factory function.


regElem Method index (src: gui-classes.psm1)

Signature

[void] regElem ( [Elem]$elem)

Parameters

Parameter Format Description

$elem Elem parm description missing

Description

Register Elem using the Elem.name property


regElem Method index (src: gui-classes.psm1)

Signature

[void] regElem ( [Elem]$elem, [string]$name)

Parameters

Parameter Format Description

$elem Elem parm description missing

$name string name to lookup

Description

Register Elem using the $name parameter as the name


regFont Method index (src: gui-classes.psm1)

Signature

[void] regFont ( [string]$name, [Drawing.Font]$font)

Parameters

Parameter Format Description

$name string name to lookup

$font Drawing.Font parm description missing

Description

Register a font by name


regIcon Method index (src: gui-classes.psm1)

Signature

[void] regIcon ( [string]$name, [Drawing.BitMap]$icon)

Parameters

Parameter Format Description

$name string name to lookup

$icon Drawing.BitMap parm description missing

Description

Register an Icon (image) by name


remDialog Method index (src: gui-classes.psm1)

Signature

[void] remDialog ( [Dialog]$dlg)

Parameters

Parameter Format Description

$dlg Dialog parm description missing

Description

Remove a Dialog for the registry

Details

Automatically called by the standard Dialog close function


resize Method index (src: gui-classes.psm1)

Signature

[void] resize ()

Description

Resizes the current window

Details

This is called internally when the user resizes the Form window (typically with the mouse).

This triggers the Form layout method to be called


rgb Method index (src: gui-classes.psm1)

Signature

[string] rgb ( [int]$red, [int]$green, [int]$blue)

Parameters

Parameter Format Description

$red int red component of RGB value

$green int green component of RGB value

$blue int blue component of RGB value

Description

Calculate the color value using RGB values


setConfirmClose Method index (src: gui-classes.psm1)

Signature

[Form] setConfirmClose ( [object]$ctx, [ScriptBlock]$confirmClose)

Parameters

Parameter Format Description

$ctx object parm description missing

$confirmClose ScriptBlock parm description missing

Description

Sets or removes confirmClose property

Details


showForm Method index (src: gui-classes.psm1)

Signature

[void] showForm ()

Description

shows the form

Details

This shows the form and freezes the Powershell console window. ?@hlog@? messages and its varients are still displayed.

A keyboard listener is installed so that the keyboard can be used to close the window. The following keyboard sequences have meaning. All others are ignored but forwarded to controls that accept keyboard input.

  • .. Terminate and restart GUI window. Used if script is changed
  • // Terminate and restart GUI driver and then GUI window. Used if underlying GUI is changed. Implies things were started with the ?@New@?
  • ./ Just terminate with no restart

Refer to ?@GuiRestart@? for more details.

PSEC - Powershell Enhanced Capability
1.2.1

Copyright © 2018-2021, 2022, Rexcel System Inc.

 

 

 

 

 

X