コード例 #1
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'daysDataSet1.Alarm' table. You can move, or remove it, as needed.
            this.alarmTableAdapter.Fill(this.daysDataSet1.Alarm);
            //Properties.Settings.Default.Reset();                                            //Reset settings; THIS IS JUST FOR DEBUGING

            //Check if there is no password (indicates program was launched for the first time)
            if (Properties.Settings.Default.password == "")
            {
                //If so then show a dialog to create a new password
                Dialogs.NewPassword newpw = new Dialogs.NewPassword();
                newpw.ShowDialog();
            }
            else
            {
                //Otherwise just confirm the login before any changes takes place
                Dialogs.ConfirmPassword confirmPw = new ConfirmPassword();
                confirmPw.ShowDialog();

                if (confirmPw.pwConfirmed == false)
                {
                    disableApplication();
                }
            }

            //Show a notification
            notifyIcon1.Icon            = SystemIcons.Application;
            notifyIcon1.BalloonTipTitle = "MrLock is giving you example of notification.";
            notifyIcon1.BalloonTipText  = @"Here you will see notifications when you have 30 minutes 
left until the computer gets automatically locked.";
            notifyIcon1.ShowBalloonTip(1000);

            ////Connect to db
            //SqlConnection connection = new SqlConnection();
            //connection.ConnectionString = @"Data Source=.\SQLEXPRESS;
            //              AttachDbFilename=/Databases/Days.mdf;
            //              Integrated Security=True;
            //              Connect Timeout=30;
            //              User Instance=True"; //Declare the connection string

            ////Try to connect
            //try
            //{
            //    connection.Open();                                                          //Open the connection
            //    toolStripStatusLabel2.Text = "Connection was Successful.";
            //}
            //catch (SqlException ex)
            //{
            //    toolStripStatusLabel2.Text = "Connection was Unsuccessful.";
            //    toolStripStatusLabel2.Click += (ss, ee) => MessageBox.Show("This is the error\n" + ex.Message, "Error",
            //        MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}


            //connection.Close();                                                         //Close the connection
        }
コード例 #2
0
        private void enableApplicationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Confirm if the password is correct or no
            Dialogs.ConfirmPassword confirmPw = new ConfirmPassword();
            confirmPw.ShowDialog();

            if (confirmPw.pwConfirmed == true)
            {
                enableApplication();
            }
        }
コード例 #3
0
        private void lockApplicationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Confirm if the password is correct or no
            Dialogs.ConfirmPassword confirmPw = new ConfirmPassword();
            confirmPw.ShowDialog();

            if (confirmPw.pwConfirmed == true)
            {
                disableApplication();
                this.Hide();
                applicationState            = enums.ApplicationState.Hidden;
                notifyIcon1.BalloonTipTitle = "MrLock Says...";
                notifyIcon1.BalloonTipText  = @"The application is now locked and started in the background, no one will be able to stop/exit it unless the password is entered.";
                notifyIcon1.ShowBalloonTip(1000);
            }
        }
コード例 #4
0
        private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Confirm if the password is correct or no
            Dialogs.ConfirmPassword confirmPw = new ConfirmPassword();
            confirmPw.ShowDialog();

            if (confirmPw.pwConfirmed == true)
            {
                notifyIcon1.Visible = false;
                notifyIcon1.Dispose();
                Environment.Exit(0);
            }
            else
            {
                e.Cancel = true;
            }
        }
コード例 #5
0
        private void showHideApplicationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            switch (applicationState)
            {
            case enums.ApplicationState.Shown:
                this.Hide();
                applicationState = enums.ApplicationState.Hidden;
                break;

            case enums.ApplicationState.Hidden:
                //Confirm if the password is correct or no
                Dialogs.ConfirmPassword confirmPw = new ConfirmPassword();
                confirmPw.ShowDialog();

                if (confirmPw.pwConfirmed == true)
                {
                    this.Show();
                }

                applicationState = enums.ApplicationState.Shown;
                break;
            }
        }