C #: Implementing Pallets

Source: Internet
Author: User

1. Add the following controls to the form: MenuStrip menuStrip1, NotifyIcon ni_frmmain,timer timer1, Contentmenustrip cms_notify. Where the notify contains display, exit, and so on.

2, the implementation of the Code:

        #regionPallet-related Code#regionPrivate method handles the display of the form hidden close (exit)/// <summary>        ///Show/// </summary>        Private voidShowmainform () { This.            Show ();  This. WindowState = This. lastformstate;  This.            Activate ();  This. ShowInTaskbar =true;//Show form icon in taskbar//this.ni_frmMain.Visible = false;//hide icon in disc        }        /// <summary>        ///Hidden/// </summary>        Private voidHidemainform () { This.            Hide ();  This. ShowInTaskbar =false;//Show form icon in taskbar//this.ni_frmMain.Visible = true;//hide icon in disc        }        /// <summary>        ///Close (exit)/// </summary>        Private voidExitmainform () {if(MessageBox.Show ("Are you sure you want to exit the main program? ","Confirm Exit", Messageboxbuttons.okcancel, messageboxicon.question, messageboxdefaultbutton.button2) = =DialogResult.OK) { This. ni_frmmain.visible =false;  This.                Close ();  This.                Dispose ();            Application.exit (); }        }        #endregion        #regionRight-click menu processing, Show hidden exit/// <summary>        ///Show/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidTsmi_notifyshow_click (Objectsender, EventArgs e)        {Showmainform (); }        /// <summary>        ///Hidden/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidTsmi_notifyhide_click (Objectsender, EventArgs e)        {Hidemainform (); }        /// <summary>        ///Exit/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidTsmi_notifyexit_click (Objectsender, EventArgs e)        {Exitmainform (); }        #endregion        #regionPrivate method when you double-click a pallet label, the form is displayedPrivate voidNi_frmmain_doubleclick (Objectsender, EventArgs e) {            if( This. WindowState = =formwindowstate.minimized) {showmainform (); }            Else            {                 This. WindowState =formwindowstate.minimized;            Hidemainform (); }        }        #endregion        #regionMinimized to pallet when the button is minimized.Private voidFrmmain_sizechanged (Objectsender, EventArgs e) {            if( This. WindowState! =formwindowstate.minimized) { This. ShowInTaskbar =true;//the form icon in the taskbar displays//this.ni_frmMain.Visible = false;                 This. lastformstate = This.            WindowState; }            Else{hidemainform (); }        }        #endregion        #regionMinimize to pallet when form is closedPrivate voidFrmmain_formclosing (Objectsender, FormClosingEventArgs e) {            //E.cancel = true; //This .  ShowInTaskbar = false; //form icon disappears in taskbar//this.ni_frmMain.Visible = true; //hidetipform ();        }        #endregion        #regionIcon blinking on off/// <summary>        ///Open/// </summary>        Private voidStartflicker () { This. timer1. Enabled =true;  This. Timer1.        Start (); }        /// <summary>        ///Close/// </summary>        Private voidCloseflicker () { This. Timer1.            Stop ();  This. timer1. Enabled =false;  This. Ni_frmmain.icon =Truelore.Fare.Client.Properties.Resources.truelore0; }        Private inti =0; Private voidTimer1_Tick (Objectsender, EventArgs e) {            if(I <1)            {                 This. Ni_frmmain.icon =Truelore.Fare.Client.Properties.Resources.truelore0; I++; return; }            Else            {                 This. Ni_frmmain.icon =Truelore.Fare.Client.Properties.Resources.truelore1; I=0; }        }        #endregion        #endregion
View Code

C #: Implementing Pallets

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.