Animation on Window Close

Answered
0
0

Hi.

I am applying a slideRightIn Animation when a window opens (appear event), which works perfectly.
Now I am trying to apply another Animation when it is closed, with a slideRightOut. I have added another Animation control and set the window properties to it. I have tried the events “close” and “disappear”, with no success.
Is even possible to have it working? I guess the window is destroyed before the Animation is able to execute, but maybe there is a way to accomplish that. Any ideas?

Thanks in advance.

Ivan

  • You must to post comments
Best Answer
0
0

Modal dialogs are a bit trickier because they are reusable and not automatically disposed.

A non-modal form gets disposed when closed, so the animation extender can “inject” itself into the destroy() method on the client and run the animation before destroying the form. Forms can also be hidden instead of closed, and in that case you can animate the “disappear” event: the  animation extender “injects” itself into the hide() method and runs the animation before hiding.

A modal dialog is not disposed, so when closed it’s hidden since the code may show it again. In that case you have to attach the animation to the “disappear” event not “close”. But… if you use the using() pattern or dispose the dialog when closed it triggers both events, first the dialog is hidden (disappear event) and then destroyed (close event).

I don’t know if we can change the animation extender to do both without breaking animated panels. But if you add a third animation extender and animate both “disappear” and “close” it works well also for modal dialog whether they are disposed or not.

 

  • Ivan Borges
    Thank you Luca. All working fine.
  • You must to post comments
Best Answer
0
0

Hi Ivan,

#2433 is fixed in Wisej release 2.2.14.

Best regards
Frank

 

  • Ivan Borges
    Excellent! Thank you.
  • You must to post comments
0
0

Hi Frank.

Would it be possible to make it work for Dialog (.ShowDialog) forms too?
The same thing happens, it works for the “appear” event, but not for the “close”.

Cheers.

Ivan

  • You must to post comments
0
0

Hi Ivan,

this issue is logged as #2433 and we´ll inform you when a fix is available.

Best regards
Frank

  • Ivan Borges
    Thanks Frank! The solution I have applied has been working well, but it will definitely be better dealt by you guys. Cheers.
  • You must to post comments
0
0

Hi.

Not sure it is the best solution, but I managed to make it work dealing with the Window FormClosing and the Animation End events.


        private bool _ClosingWindowAnimationHasPlayed = false;

        private void MyWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_ClosingWindowAnimationHasPlayed == false)
            {
                e.Cancel = true;
                this.animation2.Run(this);
            }
        }

        private void animation2_End(object sender, AnimationEventArgs e)
        {
            _ClosingWindowAnimationHasPlayed = true;
            this.animation2.ResetAnimation(this);
            this.Close();
        }


  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.