Delegate Event

                logon = new Logon();
                logon.LoginChangeEvent += new Logon.LoginChangeDelegate(logon_LoginChangeEvent);
                logon.CloseEvent += new Logon.CloseDelegate(logon_CloseEvent);

       //Login
        private void logon_LoginChangeEvent(UserType type)
        {
            this.ChangeScreen(this.mainForm);
        }

        //Application Exit
        private void logon_CloseEvent()
        {
            //this.Visible = false;
            //this.Close();
            this.Hide();
            Application.Exit();
        }

-------------------------------------------------------------------------------------------
public delegate void LoginChangeDelegate(UserType type);
        public event LoginChangeDelegate LoginChangeEvent;

        public delegate void CloseDelegate();
        public event CloseDelegate CloseEvent;


//Exit
        private void btnExit_Click(object sender, EventArgs e)
        {
            if (this.CloseEvent != null)
            {
                this.CloseEvent();
            }
        }

//Login
if (this.LoginChangeEvent != null)
                {
                    this.LoginChangeEvent(UserType.Employee);
                }

posted @ 2008-07-22 10:40  RobotTech  阅读(296)  评论(0编辑  收藏  举报