Closing opacity animation for toast window

This commit is contained in:
Jaex 2013-12-29 12:13:19 +02:00
parent 50d5894095
commit 13206ac96d
4 changed files with 33 additions and 3 deletions

View file

@ -36,12 +36,17 @@ private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tDuration = new System.Windows.Forms.Timer(this.components);
this.tOpacity = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// tDuration
//
this.tDuration.Tick += new System.EventHandler(this.tDuration_Tick);
//
// tOpacity
//
this.tOpacity.Tick += new System.EventHandler(this.tOpacity_Tick);
//
// NotificationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -63,6 +68,7 @@ private void InitializeComponent()
#endregion
private System.Windows.Forms.Timer tDuration;
private System.Windows.Forms.Timer tOpacity;
}
}

View file

@ -71,9 +71,27 @@ private void tDuration_Tick(object sender, EventArgs e)
tDuration.Stop();
if (!mouseInside)
{
StartClosing();
}
}
private void StartClosing()
{
Opacity = 1;
tOpacity.Start();
}
private void tOpacity_Tick(object sender, EventArgs e)
{
if (Opacity <= 0.05f)
{
Close();
}
else
{
Opacity -= 0.05f;
}
}
protected override void OnPaint(PaintEventArgs e)
@ -114,7 +132,7 @@ public static void Show(int duration, Size size, string imagePath, string url)
public static void Show(string imagePath, string url)
{
Show(5000, new Size(400, 300), imagePath, url);
Show(4000, new Size(400, 300), imagePath, url);
}
private void NotificationForm_MouseClick(object sender, MouseEventArgs e)
@ -133,6 +151,9 @@ private void NotificationForm_MouseEnter(object sender, EventArgs e)
{
mouseInside = true;
tOpacity.Stop();
Opacity = 1;
ToastText = URL;
Refresh();
}
@ -143,7 +164,7 @@ private void NotificationForm_MouseLeave(object sender, EventArgs e)
if (durationEnd)
{
Close();
StartClosing();
}
}
}

View file

@ -120,4 +120,7 @@
<metadata name="tDuration.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="tOpacity.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>120, 17</value>
</metadata>
</root>

View file

@ -296,7 +296,7 @@ public class TaskSettingsAdvanced
[Category("After upload"), DefaultValue(""), Description("Balloon tip content format after uploading. Supported variables: $result, $url, $shorturl, $thumbnailurl, $deletionurl, $filepath, $filename, $filenamenoext, $folderpath, $foldername, $uploadtime and other variables such as %y-%mo-%d etc.")]
public string BalloonTipContentFormat { get; set; }
[Category("After upload"), DefaultValue(5f), Description("How much toast window will stay on screen.")]
[Category("After upload"), DefaultValue(4f), Description("How much toast window will stay on screen.")]
public float ToastWindowDuration { get; set; }
[Category("After upload"), DefaultValue(typeof(Size), "400, 300"), Description("Maximum toast window size.")]