【IT168技术文档】
NotifyWindow显示一种MSN Messenger 风格的通知窗体. 如果你只准备显示文本,轻量级的NotifyWindow 就足够了.在打开和关闭NotifyWindow通知窗体时有向上/下平移的动画效果.窗体默认显示11秒,当然代码里可以改. NotifyWindow自己负责所有的窗体绘制工作,无需其他图片文件.
一个非常简单的示例:
有字体和颜色等选项可随意改变. 下载代码中的TestNotifyWindow应用程序可以让你和看到一些选项的设置,但下面的代码更全面地展示了所有选项的设置.// Display the text "This is a sample NotifyWindow" NotifyWindow nw = new NotifyWindow ("This is a sample NotifyWindow"); nw.Notify(); // The following two lines of code will display a window that // looks exactly like the one shown at the beginning of this article. NotifyWindow nw = new NotifyWindow ("NotifyWindow", "This is a sample notification created with NotifyWindow"); nw.Notify();
NotifyWindow nw = new NotifyWindow(); nw.Text = "This is the NotifyWindow text"; nw.Title = "Title Text"; // Change the background style. Other valid // styles are Solid, VerticalGradient, // HorizontalGradient and BackwardDiagonalGradient // (Default: VerticalGradient) nw.BackgroundStyle = NotifyWindow.BackgroundStyles.ForwardDiagonalGradient; // Change the background colors // (Default: BackColor=SteelBlue, GradientColor=WhiteSmoke) nw.BackColor = Color.SpringGreen; nw.GradientColor = Color.White; // Change the text and title colors. (Default: ControlText) nw.TextColor = Color.Blue; nw.TitleColor = Color.Black; // Change the color displayed when the text is pressed. (Default: Gray) nw.PressedColor = Color.Red; // Use non-default fonts. If TitleFont is not set // by the user, nw.Font will be used. nw.Font = new Font ("Tahoma", 8.25F); nw.TitleFont = new Font ("Tahoma", 8.25F, FontStyle.Bold); // Change NotifyWindow size. (Default: 130, 110) nw.SetDimensions (nwWidth, nwHeight); // Do not close the NotifyWindow if the mouse // cursor is over the window. (Default: true) nw.WaitOnMouseOver = true; // Set up an EventHandler to be called if the text or title are clicked. nw.TextClicked += new System.EventHandler (nwTextClicked); nw.TitleClicked += new System.EventHandler (nwTitleClicked); // Display the window for 20 seconds, or 20000ms. (Default: 11000ms) nw.WaitTime = 20000; // Now show the NotifyWindow. nw.Notify();