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.
Target
: string
GetSize(string, font)
returns the size of the specified text when drawn with the specified font.
Usage:
string str = "This is string";
Size strSize = str.GetSize(Font);
//OR
string str = "This is string";
Size strSize = SaaExtensions.GetSize(str, Font);
Target
: string[]
ToList(string[])
converts string array to List.
Usage:
string[] strArray = { "Cat", "Dog", "Goat" };
List<string> list = strArray.ToList();
//OR
string[] strArray = { "Cat", "Dog", "Goat" };
List<string> list = SaaExtensions.ToList(strArray);
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:
Size TotalSize = saaToast1.GetSize();
Size BottomLeftSize = saaToast1.GetSize(ToastPosition.BottomLeft);
//OR
Size TotalSize = SaaExtensions.GetSize(saaToast1);
Size BottomLeftSize = SaaExtensions.GetSize(saaToast1, ToastPosition.BottomLeft);
Target: Color
ToHex(Color)
converts color to hexadecimal like #FFFF00
.
ToRGB(Color)
converts color to RGB like RGB(255,255,0)
.
Usage:
Color _color = Color.Red;
string hexColor = _color.ToHex();
string rgbColor = _clor.ToRGB();
//OR
Color _color = Color.Red;
string hexColor = SaaExtensions.ToHex(_color);
string rgbColor = SaaExtensions.ToRGB(_color);
Property: string
NewID
generates globally unique ids with no duplicates possible.
Usage:
string Id = SaaExtensions.NewID;
Target: Color
GetTransparency(Color, Percentage)
makes a color transparent in the given percentage.
Usage:
Color _color = Color.Red;
Color halfTranparentColor = _color.GetTransparency(50);
//OR
Color _color = Color.Red;
Color halfTranparentColor = SaaExtensions.GetTransparency(_color, 50);
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:
point location = button1.LocationRelativeToForm();
//OR
point location = SaaExtensions.LocationRelativeToForm(button1);
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:
point Mouselocation = button1.MouseLocation();
//OR
point Mouselocation = SaaExtensions.MouseLocation(button1);
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:
point InnerMouseLocation = button1.InnerMouseLocation();
//OR
point InnerMouseLocation = SaaExtensions.InnerMouseLocation(button1);
Target: Control
SetDoubleBuffering(Control, true/false)
enables or disables doubleBuffering for a control.
Usage:
button1.SetDoubleBuffering(true/false);
//OR
SaaExtensions.SetDoubleBuffering(button1, true/false);
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:
string[] str = { "Cat", "Dog", "Chicken"};
bool isContains = str.Contains("dog"); //returns true
bool isContains = str.Contains("dog", true); //returns false
//OR
bool isContains = SaaExtensions.Contains(str, "dog", [ true/false]);
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:
button2.CopyPropertiesFrom(button1, {"BackColor", "Font", "Text"}); // Copies BackColor, Font and Text from button1 to button2.
button2.CopyPropertiesFromExcept(button1, {"BackColor", "Text"}); // Copies all properties except BackColor,and Text from button1 to button2.
//OR
SaaExtensions.CopyPropertiesFrom(button2, button1, {"BackColor", "Font", "Text"});
SaaExtensions.CopyPropertiesFromExcept(button2, button1, {"BackColor", "Text"});
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:
myForm.SetProperty("BackColor", Color.Blue);
Color bc = (Color)myForm.GetProperty("BackColor");
//OR
SaaExtensions.SetProperty(myForm1, "BackColor", Color.Blue);
Color bc = (Color)SaaExtensions.GetProperty(myForm1, "BackColor");
Last updated
Was this helpful?