Banner with Code

Upcoming Release

Prerelease: v1.4.0-alpha

Take me back to current documentation!

Changes

What's upcoming for AnimateForms v1.4.0a? Changes are highlighted in yellow and additions are highlighted in green.


Animate.cs

View Changes

Behavioural and feature updates.

Helpers.cs

View Changes

API change for code clarity.

Options.cs

View Changes

Added new alignment option for resizing controls.




Animate.cs Members

Class Information

Instantiable

To start using the animate functions, first declare an animator:

private Animate a = new Animate();

Then, any animated method is run as such:

await a.Method(parameters);


AnimateForms used to return false if the animate call would result in nothing happening (e.g. moving a control to (0, 0) when it was already there). However, if it was called using an options object as a parameter, it would still follow through with the pre/post end delays, following through with the actual animation delay depending on the last control in the Options object. This could potentially result in erratic behaviour in certain edge cases, and so it has been modified so calls using Options must always complete their delay, interval, duration, end sequences. This comes with some performance benefits as well.


ProTip #1: By specifying await, the method is run synchronously and will not allow code to continue before the method has finished executing. Instead, a discard can be used to run asynchronously:

_ = a.Method(parameters);

ProTip #2: Animate classes will block two animations of the same type on the same control (unless otherwise noted in documentation). This prevents jittery graphics as two animations try to happen at once. As such, only one Animate class should ever be declared in your code.

Resize

Input: Control control, Function easing, int duration, Size sizeTo

Output: bool

Resizes input control to input sizeTo, using the specified duration and easing function. Returns true if animation completed and false if sizeTo is equal to current size or another Resize is currently being run on the control.


See Also:

Animate.Function

Options


Examples:

_ = a.Resize(control, Easings.Linear, 1000, new Point(200, 200));

_ = a.Resize(new Options(), new Size(200, 200));


Overloads:

Options o, Size sizeTo

Applies animation using an Options object. See the Options documentation for possible modifiers.

Options o, int? width = null, int? height = null

Resizes controls while preserving a dimension. E.g. if height was left null but width was set to 0, all controls selected by the options would animate to 0px wide while preserving their individual heights.


Helpers.cs Members

Class Information

Static

The Helpers class is a static class containing useful methods relating to, but not necessary to AnimateForms. In v1.4.0a, Helper methods like CollectionToArray will be renamed to shorter things like ToArray and be converted to extension methods for their respective inputs. Their function will remain the same. If desired, extension methods can be called using the old method, passing in an argument into the method.

ToArray (static, extension: Control.ControlCollection)

Extension: controlCollection.ToArray();

Output: Control[]

Converts a ControlCollection that results from calling parentControl.Controls to a control array for use in the animation functions.


ProTip: ControlCollections seem to be organized randomly, and you should only use this function when the resulting order of the array doesn't matter.

ToRGB (static, extension: HSV)

Extension: hsv.ToRGB();

Output: System.Drawing.Color

Converts an HSV object into a System.Drawing.Color RGB color.

ToHSV (static, extension: System.Drawing.Color)

Extension: color.ToHSV();

Output: HSV

Converts an RGB System.Drawing.Color color into an HSV object. If an alpha is provided, it will be ignored.

SortByName (static, extension: Control.ControlCollection)

Extension: controlCollection.SortByName();

Output: Control[]

Converts a ControlCollection that results from calling parentControl.Controls to a control array, which is sorted by the control's Name property in alphabetical order.

Options.cs Members

Options

Parameters: Control control, Function easing, int duration

Optional Parameters: Control[] controls*, Function[] easings*, int delay, int interval

Non-Constructor Paramters: int endDelay

An options object to allow greater control over some animation functions. It can be created by using a constructor with parameters or by setting each element individually. Currently, all animations will accept an options object and will process all parameters set in one, since the options are universal.


See Also: Animate.Function


Alignment: Uses the Alignment enumerable. Determines transform origin of control for resizing.

Easing: Easing function to use. Default = Linear.

Duration: Duration of animation, in milliseconds. Default = 1000ms.

Delay: Delay before animation starts.** Default = 0ms.

EndDelay: Delay after animation ends.** Default = 0ms.

Interval: Time between animations executing in bulk animation commands. Default = 0ms.


*Single control and single functions that get passed in as parameters get parsed into an array by the Options object anyway.

**If this is specified and the animation returns or will return false, it will still wait for this amount of time.


Alignment

Enumerable

An enumerable that determines the control's transform origin during resize.


Default - Top left aligned (default)

HorizontalCenter - Aligned to the top and horizontally centered

VerticalCenter - Aligned to the left and vertically centered

AbsoluteCenter - Aligned to the very middle of the control

Right - Top right aligned

Bottom - Bottom left aligned