// 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();
以上代码实现的窗体效果如下图
程序员也可以通过nw.Blend and nw.StringFormat来定制背景, Text 和 Title