/// <summary> /// 释放资源 /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { if (disposing) { } if (Timer != null) { Timer.Dispose(); } if (_backImage != null) { _backImage.Dispose(); } if (_splitImage != null) { _splitImage.Dispose(); } if (_notifyFont != null) { _notifyFont.Dispose(); _notifyFont = null; } if (Notify != null) { Notify.Dispose(); Notify = null; } base.Dispose(disposing); }
/// <summary> /// 执行窗口动画操作 /// </summary> protected void Timer_Tick(object sender, EventArgs e) { if (Notify != null) { // 动态改变窗口位置 var pos = Notify.Height / 100; var top = Screen.PrimaryScreen.WorkingArea.Height - Notify.Height; if (Notify.Top > top + pos * 10) { for (var i = 0; i < 35; i++) { Notify.Top -= pos; } return; } Notify.Top = top; if (ShowInterval > Interval) { var count = 1; if (ShowInterval > 30) { count = ShowInterval / 5; } Timer.Interval = count * 1000 < 0 ? int.MaxValue : count * 1000; Interval += count; return; } Timer.Interval = 100; if (Notify != null) { if (Notify.Opacity > 0) // 动画降低窗口透明度 { Notify.Opacity -= 0.1; } else // 释放窗口资源 { Interval = 0; Timer.Enabled = false; Timer.Dispose(); Notify.Dispose(); Notify = null; } } } }
/// <summary> /// 将以动画的形式显示,默认存在时间为 5 秒 /// </summary> /// <param name="caption">窗口标题</param> /// <param name="text">窗口内容</param> /// <param name="timer">窗口是否计时消失</param> public void AnimalShow(string caption, string text, bool timer) { if (Notify == null) { Notify = new NotifyForm(); } if (!string.IsNullOrEmpty(caption)) { Notify.TextShow = caption; } if (!string.IsNullOrEmpty(text)) { Notify.NotifyText = text; } Timer.Interval = 100; Timer.Tick += Timer_Tick; Timer.Enabled = timer; Notify.Show(); }