示例#1
0
文件: MainForm.cs 项目: thexur/1code
        private void buttonLogoff_Click(object sender, EventArgs e)
        {
            GlobleData.IsUserLoggedIn = false;
            LoginMsg = "User Successfully logged off";

            this.Visible = false;
            loginEntry   = new LoginForm();
            if (loginEntry.ShowDialog() == DialogResult.OK)
            {
                if (this.Visible == false && GlobleData.IsUserLoggedIn)
                {
                    this.Visible = true;
                }
                LoginMsg = "User Successfully logged in";
            }
        }
示例#2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            _hide();

            LoginForm loginEntry = new LoginForm();

            if (loginEntry.ShowDialog() == DialogResult.OK)
            {
                Login();
                show();
            }
            if (GlobleData.IsUserLoggedIn == false)
            {
                Application.Exit();
            }
        }
示例#3
0
 private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
     }
     else if (e.Button == MouseButtons.Left)
     {
         FormCollection forms = Application.OpenForms;
         if (this.WindowState == FormWindowState.Minimized && forms["LoginForm"] == null)
         {
             LoginForm loginEntry = new LoginForm();
             if (loginEntry.ShowDialog() == DialogResult.OK)
             {
                 Login();
                 show();
                 CloseAllChildForm();
             }
         }
     }
 }
示例#4
0
        // The handler when attempting to start another instance of this application
        // We can customize the logic here for which form to activate in different
        // conditions. Like in this sample, we will be selectively activate the LoginForm
        // or MainForm based on the login state of the user.
        private static void StartNewInstance(object sender, StartupNextInstanceEventArgs e)
        {
            FormCollection forms = Application.OpenForms;

            if (forms["LoginForm"] != null)
            {
                forms["MainForm"].Hide();
                forms["LoginForm"].Activate();
            }
            else if (forms["LoginForm"] == null && GlobleData.IsUserLoggedIn == false)
            {
                MessageBox.Show("22");
                LoginForm f = new LoginForm();
                if (!(f.ShowDialog() == DialogResult.OK))
                {
                    forms["MainForm"].WindowState = FormWindowState.Maximized;
                    forms["MainForm"].Show();
                }
                else
                {
                    forms["MainForm"].Close();
                }
            }
            else if (forms["MainForm"] == null && GlobleData.IsUserLoggedIn == true)
            {
                MessageBox.Show("23");
                LoginForm f = new LoginForm();
                if (!(f.ShowDialog() == DialogResult.Cancel))
                {
                    forms["LoginForm"].Show();
                }
            }
            else if (forms["MainForm"] != null && GlobleData.IsUserLoggedIn == false)
            {
                LoginForm f = new LoginForm();
                if (f.ShowDialog() == DialogResult.OK)
                {
                    forms["MainForm"].WindowState = FormWindowState.Maximized;
                    forms["MainForm"].Show();
                }
            }
            else if (forms["MainForm"] != null && GlobleData.IsUserLoggedIn == true)
            {
                LoginForm f = new LoginForm();
                if (f.ShowDialog() == DialogResult.OK)
                {
                    forms["MainForm"].Show();
                    forms["MainForm"].WindowState = FormWindowState.Maximized;
                }
            }
            else if (forms["MainForm"] != null && GlobleData.IsUserLoggedIn == true && forms["MainForm"].WindowState == FormWindowState.Minimized)
            {
                MessageBox.Show("4");
                LoginForm f = new LoginForm();
                if (f.ShowDialog() == DialogResult.OK)
                {
                    forms["MainForm"].WindowState = FormWindowState.Maximized;
                    forms["MainForm"].Show();
                }
            }
            else if (forms["MainForm"] != null && GlobleData.IsUserLoggedIn == true && forms["MainForm"].WindowState == FormWindowState.Maximized)
            {
                MessageBox.Show("5");
                LoginForm f = new LoginForm();
                if (f.ShowDialog() == DialogResult.OK)
                {
                    forms["MainForm"].WindowState = FormWindowState.Maximized;
                    forms["MainForm"].Show();
                }
            }
            else
            {
                MessageBox.Show("6");
            }
        }