比较简单的一个小功能,和新毒霸类似的效果。
效果代码:
bool closeStoryBoardCompleted = false; DoubleAnimation closeAnimation1; void closeWindow_Completed(object sender, EventArgs e) { closeStoryBoardCompleted = true; this.Close(); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (!closeStoryBoardCompleted) { closeAnimation1 = new DoubleAnimation(); closeAnimation1.From = 1; //初始值 1为 整个窗体 0.1表示窗体的十分之一 closeAnimation1.To = 0; //结束值 0为完全关闭 closeAnimation1.Duration = new Duration(TimeSpan.Parse("0:0:0.3")); //所用时间的间隔 closeAnimation1.Completed += new EventHandler(closeWindow_Completed); ScaleTransform st = new ScaleTransform(); st.CenterY = this.Height / 2; //以纵向的方式缩小 this.RenderTransform = st; st.BeginAnimation(ScaleTransform.ScaleYProperty, closeAnimation1); e.Cancel = true; } }
需要窗体模板请加群
窗体模板效果图:
WPF、AE技术交流群:94234450 点击加入QQ群:不论你遇到什么问题,我们绝不会让你独自去面对!