土司风格弹出我的应用程序 [英] toast style popup for my application
问题描述
我创建了在任务栏运行的应用程序。当用户点击它会弹出应用程序等等。我想是类似的功能,在MSN的时候我的一个朋友在记录,显然这是知道作为一个面包弹出?
我基本上想要的东西,从每20分钟土司风格FOM在任务栏的弹出应用程序。
I have created an application that runs in the taskbar. When a user clicks the application it pops up etc. What I would like is similar functionality to that in MSN when one of my friends logs in. Apparently this is know as a toast popup? I basically want something to popup from every 20 minutes toast style fom the application in the taskbar.
我现有的应用程序是基于C#编写与.NET的WinForms 3.5
My existing application is winforms based written in C# with .net 3.5
干杯
推荐答案
这是非常简单的。你只需要在屏幕外的区域设置窗口动画和它的位置,直到其完全可见。下面是一个示例代码:
This is pretty simple. You just need to set window in off-screen area and animate it's position until it is fully visible. Here is a sample code:
public partial class Form1 : Form
{
private Timer timer;
private int startPosX;
private int startPosY;
public Form1()
{
InitializeComponent();
// We want our window to be the top most
TopMost = true;
// Pop doesn't need to be shown in task bar
ShowInTaskbar = false;
// Create and run timer for animation
timer = new Timer();
timer.Interval = 50;
timer.Tick += timer_Tick;
}
protected override void OnLoad(EventArgs e)
{
// Move window out of screen
startPosX = Screen.PrimaryScreen.WorkingArea.Width - Width;
startPosY = Screen.PrimaryScreen.WorkingArea.Height;
SetDesktopLocation(startPosX, startPosY);
base.OnLoad(e);
// Begin animation
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
//Lift window by 5 pixels
startPosY -= 5;
//If window is fully visible stop the timer
if (startPosY < Screen.PrimaryScreen.WorkingArea.Height - Height)
timer.Stop();
else
SetDesktopLocation(startPosX, startPosY);
}
}
这篇关于土司风格弹出我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!