User Controls: MSN Chat Window

I am interested to know about the famous MSN chat chat clients! I am sure there must be many different aspects, but I would like to focus on these small sliding panels. For example, when images of people in a conversation are displayed. When you press the minimize button, the pictures disappear and the panel gracefully slides inward, and when you press it again to expand it, it extends and the images fade out smoothly.

How would you draw a control in WinForms with similar behavior?

+5
source share
1 answer

This should give you an idea of ​​how the animation is your width.

int _collapsedWidth;
int _fullWidth;
float _speed;
float _acurateWidth;

System.Diagnostics.Stopwatch _stopwatch = new Stopwatch ();

int _animationDirection;

AnimatedControl (){

    Application.Idle += ApplicationIdle;
}

void Expand (){
    _animationDirection = 1;
    _stopwatch.Start();
}

void ApplicationIdle (object sender, EventArgs e){
    if (_animation.Direction == 0)
        return;

    float delta = _stopwatch.Elapsed.TotalMilliseconds * _speed;

    _acurateWidth += delta;

    if (_acurateWidth < _collapsedWidth)
    {
        _animationDirection = 0;
        _acurateWidth = _collapsedWidth;
        _stopwatch.Stop();              
    }
    else if (_acurateWidth > _fullWidth)
    {
        _animationDirection = 0;
        _acurateWidth = _fullWidth;
        _stopwatch.Stop();      
    }

    _stopwatch.Reset();

    this.Width = (int)System.Math.Round(_acurateWidth , MidpointRounding.AwayFromZero);
    this.Invalidate (); // May not need this

}

, , , , .

LayoutPanel, .

+2

All Articles