예제 #1
0
 public static void Fade(Form form, bool fadeIn)
 {
     if (fadeIn)
     {
         User32.AnimateWindow(form.Handle, 500, User32.AW_ACTIVATE | User32.AW_BLEND);
     }
     else
     {
         User32.AnimateWindow(form.Handle, 500, User32.AW_HIDE | User32.AW_BLEND);
     }
     //protected override void OnLoad(EventArgs e)
     //{
     //    base.OnLoad(e);
     //    User32.AnimateWindow(this.Handle, 1000, AW_ACTIVATE | (_UseSlideAnimation ?
     //                  AW_HOR_POSITIVE | AW_SLIDE : AW_BLEND));
     //}
     //protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
     //{
     //    base.OnClosing(e);
     //    if (e.Cancel == false)
     //    {
     //        AnimateWindow(this.Handle, 1000, AW_HIDE | (_UseSlideAnimation ?
     //                      AW_HOR_NEGATIVE | AW_SLIDE : AW_BLEND));
     //    }
     //}
 }
예제 #2
0
    protected override void OnClosing(CancelEventArgs e)
    {
        if (this.hasFadeCompleted)
        {
            base.OnClosing(e);
            return;
        }
        e.Cancel = true;
        var hWnd = new WindowInteropHelper(this).Handle;

        User32.AnimateWindow(hWnd, 1, AnimateWindowFlags.AW_BLEND | AnimateWindowFlags.AW_HIDE);
        Task.Factory.StartNew(() =>
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                this.hasFadeCompleted = true;
                this.Close();
            }), DispatcherPriority.Normal);
        });
    }