C# Class MCAEmotiv.GUI.Extensions

Contains useful GUI-related extension methods
Show file Open project: madelson/Emotiv-Experimenter

Public Methods

Method Description
AddContextMenu ( this clb ) : void

Adds a useful context menu to a checked list box

AsyncWaitOnGUIThread ( this condition, System.Action onComplete ) : void

OnComplete will be invoked on the GUI thread when condition is true. This function need not be called from the GUI thread.

Center ( this rectangle ) : Point

The point at the center of the rectangle.

CenteredAround ( this size, Point location ) : Point

Returns the point where this is centered around the location.

ConstrainedTo ( this size, Size container ) : Size

If size fits inside the containing size, the original size is returned. Otherwise, a size is returned that is as large as possible, fits within the container, and has the same aspect ratio as the original size.

DrawArrow ( this graphics, Rectangle area, ArrowType arrowType, double ratio = 1.0/3.0 ) : void

Draws an arrow in the specified rectangle with the specified direction. Ratio is used on recursive calls withing this function to adjust the sizing of bidirectional arrows

DrawFixationCross ( this graphics, Point center ) : void

Draws a fixation cross centered at location

EnableValidation ( this textBox, bool>.Func isValid, System.Action onValidTextEntered = null ) : void

Adds fancy validation logic using isValid to determine the validity of the textbox's content. The onValidTextEntered function, if not null, is called from the TextChanged event only if the new text was valid.

GUIInvoke ( this action ) : void

Invokes the action on the GUI thread if necessary.

IsValid ( this textBox ) : bool

Returns true iff there is no validation function installed for the text box or if the current text value is declared valid by the installed validation function

ReverseTabOrder ( this control ) : void

Reverses the tab order of the control's children.

ToLabel ( this text, DockStyle dockStyle = DockStyle.Top, ContentAlignment align = ContentAlignment.TopLeft, bool autoSize = true ) : Label

Creates a label from text. The default DockStyle is set for usage in a top-down FlowLayoutPanel.

TryLoadImage ( this path, Image &image ) : bool

If Image.FromFile succeeds and the result is not null, returns true and assigns the loaded value to image. Otherwise, image is set to null and false is returned.

Private Methods

Method Description
AsyncWaitOnGUIThreadHelper ( this condition, System.Action onComplete ) : void

Method Details

AddContextMenu() public static method

Adds a useful context menu to a checked list box
public static AddContextMenu ( this clb ) : void
clb this
return void

AsyncWaitOnGUIThread() public static method

OnComplete will be invoked on the GUI thread when condition is true. This function need not be called from the GUI thread.
public static AsyncWaitOnGUIThread ( this condition, System.Action onComplete ) : void
condition this
onComplete System.Action
return void

Center() public static method

The point at the center of the rectangle.
public static Center ( this rectangle ) : Point
rectangle this
return Point

CenteredAround() public static method

Returns the point where this is centered around the location.
public static CenteredAround ( this size, Point location ) : Point
size this
location Point
return Point

ConstrainedTo() public static method

If size fits inside the containing size, the original size is returned. Otherwise, a size is returned that is as large as possible, fits within the container, and has the same aspect ratio as the original size.
public static ConstrainedTo ( this size, Size container ) : Size
size this
container System.Drawing.Size
return System.Drawing.Size

DrawArrow() public static method

Draws an arrow in the specified rectangle with the specified direction. Ratio is used on recursive calls withing this function to adjust the sizing of bidirectional arrows
public static DrawArrow ( this graphics, Rectangle area, ArrowType arrowType, double ratio = 1.0/3.0 ) : void
graphics this
area System.Drawing.Rectangle
arrowType ArrowType
ratio double
return void

DrawFixationCross() public static method

Draws a fixation cross centered at location
public static DrawFixationCross ( this graphics, Point center ) : void
graphics this
center Point
return void

EnableValidation() public static method

Adds fancy validation logic using isValid to determine the validity of the textbox's content. The onValidTextEntered function, if not null, is called from the TextChanged event only if the new text was valid.
public static EnableValidation ( this textBox, bool>.Func isValid, System.Action onValidTextEntered = null ) : void
textBox this
isValid bool>.Func
onValidTextEntered System.Action
return void

GUIInvoke() public static method

Invokes the action on the GUI thread if necessary.
public static GUIInvoke ( this action ) : void
action this
return void

IsValid() public static method

Returns true iff there is no validation function installed for the text box or if the current text value is declared valid by the installed validation function
public static IsValid ( this textBox ) : bool
textBox this
return bool

ReverseTabOrder() public static method

Reverses the tab order of the control's children.
public static ReverseTabOrder ( this control ) : void
control this
return void

ToLabel() public static method

Creates a label from text. The default DockStyle is set for usage in a top-down FlowLayoutPanel.
public static ToLabel ( this text, DockStyle dockStyle = DockStyle.Top, ContentAlignment align = ContentAlignment.TopLeft, bool autoSize = true ) : Label
text this
dockStyle DockStyle
align ContentAlignment
autoSize bool
return System.Windows.Forms.Label

TryLoadImage() public static method

If Image.FromFile succeeds and the result is not null, returns true and assigns the loaded value to image. Otherwise, image is set to null and false is returned.
public static TryLoadImage ( this path, Image &image ) : bool
path this
image Image
return bool