Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2401

WinForms Transition Manager (New in v14.1)

$
0
0

Among many new controls and features in v14.1, we have also introduced a new non visual component, a Transition Manager. A Transition Manager takes care of animations when switching from one UI view to the next. What's cool is that not only views could be animated, but also anything that changes a visual state.

For instance, suppose we want to change the background of a container:

To animate this change, simply wrap the code you had before inside a transaction, like so:

private void colorPickEdit_EditValueChanged(object sender, EventArgs e) {
    if (transitionManager1.IsTransaction) {
        transitionManager1.EndTransition();
    }

    transitionManager1.StartTransition(containerPanel);
    try {

        containerPanel.BackColor = colorPickEdit.Color;

    } finally {
        transitionManager1.EndTransition();
    }
}

Similarly, if for instance we want to navigate from a view of Customers to a view of Employees:

T Find<T>(Control container) where T : Control {
    for (int i = 0; i < container.Controls.Count; i++) {
        if (container.Controls[i] is T) {
            return (T)container.Controls[i];
        }
    }
    return null;
}

void ChangeView<T>() where T : Control, new()  {
    if (transitionManager1.IsTransaction) {
        transitionManager1.EndTransition();
    }

    transitionManager1.StartTransition(containerPanel);
    try {

        T find = Find<T>(containerPanel);
        if (find != null) {
            find.BringToFront();
        } else {
            find = new T();
            find.Parent = containerPanel;
            find.Dock = DockStyle.Fill;
            find.BringToFront();
        }

    } finally {
        transitionManager1.EndTransition();
    }
}


To try this for yourself: Download Sample


Cheers,

Azret





Viewing all articles
Browse latest Browse all 2401

Trending Articles