SaaExtensions
This documentation is for SaaUI 1.1.0. If you using older version please update to latest version.
Type
: Class
Contains useful extension methods that you may find helpful.
Make sure you add namespace using SaaUI;
Target
: string
GetSize(string, font)
returns the size of the specified text when drawn with the specified font.
Usage:
Target
: string[]
ToList(string[])
converts string array to List.
Usage:
Target: SaaToast
GetSize(SaaToast)
Gets the total Size (including Offsets) of all toasts that are open and visible on the screen.
GetSize(SaaToast, ToastPosition)
Gets the total Size (including Offsets) of all toasts that are open and visible on the screen in the specified position.
Usage:
Target: Color
ToHex(Color)
converts color to hexadecimal like #FFFF00
.
ToRGB(Color)
converts color to RGB like RGB(255,255,0)
.
Usage:
Property: string
NewID
generates globally unique ids with no duplicates possible.
Usage:
The possibility of generating same Ids for lifetime globally is 0%. This means you can rely on it without fearing of getting duplicate ids even if you are generating billions of ids per second.
It uses several individually generated universally unique identifier (UUID) + locally created custom identifiers.
Target: Color
GetTransparency(Color, Percentage)
makes a color transparent in the given percentage.
Usage:
Target: Control
LocationRelativeToForm(Control)
returns the location of a control relative to where it appears on the form. No matter if the control is inside other containers or nested containers. This is different from Control.Location
. Control.Location
returns the location of the control relative to its parent container(panel, form etc).
Assuming you have a button in a panel on a form, see the illustrations below.
Usage:
Target: Control
MouseLocation(Control)
returns mouse location of a control relative to the parent form. If the mouse pointer is outside the form then it returns Point.Empty
.
Usage:
Target: Control
InnerMouseLocation(Control)
returns mouse location of a control relative to itself. If the mouse pointer is outside the control then it returns -1 (both X and Y).
Usage:
Target: Control
SetDoubleBuffering(Control, true/false)
enables or disables doubleBuffering for a control.
Usage:
Target: String[]
Contains(string[], item, caseSensitive)
checks whether string array has the specified item in its collection. caseSensitive
is optional argument and tells whether case-sensitivity must be respected. I.e with caseSensitive
set true
, Name and name are not same.
Usage:
Target: Control
CopyPropertiesFrom(ToControl, FromControl, PropertiesToCopy)
copies specified propeties from one control to another.
CopyPropertiesFromExcept(ToControl, FromControl, PropertiesNotToCopy)
copies all properties except the ones specified from one control to another.
Imaging you have designed a beautiful button and you want another button to have same design. Instead of again designing that button, you can just copy from the other one. I.e Color, Text, Icon etc. Works with any control.
Usage:
Target: Object
GetProperty(object, propertyName)
returns property value of an object.
SetProperty(object, propertyName, value)
sets value to a property of an object. An object
can be anything like class
, Button
, Form
. In the following example we assume the object
to be a Form
.
Usage:
Last updated