Esempio n. 1
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     // Left Key
     if (keyData == Keys.Left && !userInputTextBox.Focused)
     {
         PreviousButton.PerformClick();
         return(true);
     }
     // Right Key
     else if (keyData == Keys.Right && !userInputTextBox.Focused)
     {
         NextButton.PerformClick();
         return(true);
     }
     // Space Key
     else if (keyData == Keys.Space && !userInputTextBox.Focused)
     {
         cardButton.PerformClick();
         return(true);
     }
     // Enter Key
     else if (keyData == Keys.Enter && userInputTextBox.Focused)
     {
         AddAnotherAnswerButton.PerformClick();
         cardButton.Focus();
         return(true);
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
Esempio n. 2
0
        private void MainForm_KeyUp(object sender, KeyEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(new KeyEventHandler(MainForm_KeyUp), sender, e);
                return;
            }

            if (e.KeyCode == Keys.Back ||
                e.KeyCode == Keys.BrowserBack ||
                (e.Alt && e.KeyCode == Keys.Left))
            {
                BackButton.PerformClick();
                return;
            }

            if (e.KeyCode == Keys.BrowserForward ||
                (e.Alt && e.KeyCode == Keys.Right))
            {
                NextButton.PerformClick();
                return;
            }

            if (e.KeyCode == Keys.F5 ||
                e.KeyCode == Keys.BrowserRefresh)
            {
                RefreshButton.PerformClick();
                return;
            }
        }
Esempio n. 3
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            User userj = new User();

            userj.UserId = UserIdTextBox.Text;
            if (MessageBox.Show("Do you want to delete user " + userj.UserId + " ?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                newConnection.deleteRow(userj.UserId);
                Edit_Load(this, e);
                PrevButton.PerformClick();
                NextButton.PerformClick();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Метод для обработки события нажатия клавиш пользователем
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="keyData"></param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case Keys.Left:
                PrevButton.PerformClick();
                return(true);

            case Keys.Right:
                NextButton.PerformClick();
                return(true);
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Esempio n. 5
0
 private void CancelButton_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Do you want to cancel your edit ?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         UserIdTextBox.Enabled    = false;
         FirstNameTextBox.Enabled = false;
         LastNameTextBox.Enabled  = false;
         UpdateButton.Enabled     = false;
         CancelButton.Enabled     = false;
         FindButton.Enabled       = true;
         AddButton.Enabled        = false;
         CloseButton.Enabled      = true;
         NewButton.Enabled        = true;
         DeleteButton.Enabled     = true;
         AddButton.Enabled        = false;
         PrevButton.PerformClick();
         NextButton.PerformClick();
     }
 }
Esempio n. 6
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            User userj = new User();

            userj.UserId    = UserIdTextBox.Text;
            userj.Telephone = Int32.Parse(TelephoneMTB.Text);
            userj.Admin     = AdminCheckBox.Checked;
            if (MessageBox.Show("Do you want to update " + userj.UserId + " ?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                userj.Password = "******";
                MessageBox.Show("password  is Reset", "Reset Password", MessageBoxButtons.OK, MessageBoxIcon.Information);
                newConnection.updateRow(userj);
                Edit_Load(this, e);
            }
            else
            {
                PrevButton.PerformClick();
                NextButton.PerformClick();
            }
        }
Esempio n. 7
0
 private void Timer1_Tick(object sender, EventArgs e)
 {
     if (player.GetPosition() < MusicProgressBar.Maximum)
     {
         MusicProgressBar.Value = player.GetPosition();
         StartLabel.Text        = player.GetFormattedPosition();
     }
     else
     {
         if (ActionManager.AutoConsoleModeFromString(ConfigManager.GetProperty(PropertyItem.ConsoleOpenMode)) == ActionManager.AutoConsoleMode.Old)
         {
             ActionManager.ToggleConsole(false);
         }
         StartLabel.Text = EndTimeLabel.Text;
         PlayButton.Text = playButtonStartString;
         isDonePlaying   = true;
         timer1.Stop();
         if (NextButton.Enabled)
         {
             NextButton.PerformClick();
         }
     }
 }
Esempio n. 8
0
 private void AddButton_Click(object sender, EventArgs e)
 {
     if (UserIdTextBox.Text == "" || TelephoneMTB.Text == "" || FirstNameTextBox.Text == "" || LastNameTextBox.Text == "")
     {
         MessageBox.Show("Fields cannot be Null", "Warning !", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         User userj = new User();
         userj.UserId     = UserIdTextBox.Text;
         userj.Telephone  = Int32.Parse(TelephoneMTB.Text);
         userj.Admin      = AdminCheckBox.Checked;
         userj.Last_Name  = LastNameTextBox.Text;
         userj.First_Name = FirstNameTextBox.Text;
         userj.Password   = "******";
         if (MessageBox.Show("Do you want to add user " + userj.UserId + " ?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             newConnection.addRow(userj);
             Edit_Load(this, e);
             PrevButton.PerformClick();
             NextButton.PerformClick();
         }
     }
 }
Esempio n. 9
0
 private void NextTButton_Click(object sender, EventArgs e)
 {
     NextButton.PerformClick();
 }
Esempio n. 10
0
        public void btnCella_Click(object sender, EventArgs e)
        {
            Cella CurrentButton = sender as Cella;

            if (!((e is EventArgs) && !(e is KeyEventArgs) && !(e is MouseEventArgs)))
            {
                numberOfMoves++;
            }

            if (CurrentButton.Image != null)
            {
                lblFlags.Text       = "Bandiere: " + ++CampoMinato.flags;
                CurrentButton.Image = null;
                CurrentButton.Font  = new Font(Font.FontFamily, 8);
            }
            CurrentButton.Click    -= new EventHandler(btnCella_Click);
            CurrentButton.MouseUp  -= btnCella_MouseUp;
            CurrentButton.ForeColor = Color.Black;
            CurrentButton.BackColor = Color.LightGray;
            int minesFound = 0;

            switch (CurrentButton.Text)
            {
            case "0":
                CurrentButton.ForeColor = Color.LightGray;
                NumeroCelleLiberate++;
                string[] numeri = numeri = new string[2];
                numeri = CurrentButton.Name.Split(':');
                int RowCurrent = Int32.Parse(numeri[0]);
                int ColCurrent = Int32.Parse(numeri[1]);

                int      NextRowCurrent;
                int      NextColCurrent;
                int      NextRowButton;
                int      NextColButton;
                string[] numeriNext;

                foreach (Cella NextButton in CampoMinato.ListBtnCelle)
                {
                    numeriNext = new string[2];
                    for (int m = 0; m < 8; m++)
                    {
                        NextRowCurrent = RowCurrent + CampoMinato.PosizioniAdiacenti[m, 0];
                        NextColCurrent = ColCurrent + CampoMinato.PosizioniAdiacenti[m, 1];

                        numeriNext    = NextButton.Name.Split(':');
                        NextRowButton = Int32.Parse(numeriNext[0]);
                        NextColButton = Int32.Parse(numeriNext[1]);

                        if (NextRowCurrent == NextRowButton && NextColCurrent == NextColButton)
                        {
                            NextButton.PerformClick();
                        }
                    }
                }
                break;

            case "99":

                foreach (Cella button in CampoMinato.ListBtnCelle)
                {
                    if (button.Text == "99")
                    {
                        button.Click   -= new EventHandler(btnCella_Click);
                        button.MouseUp -= btnCella_MouseUp;
                        button.Text     = "";
                        if (button.Image == null)
                        {
                            button.Image     = Image.FromFile("../mina.gif");
                            button.BackColor = Color.Red;
                        }
                        else
                        {
                            button.Image     = Image.FromFile("../mina_scovata.gif");
                            button.BackColor = Color.Transparent;
                            minesFound++;
                        }
                        button.ForeColor = Color.Black;
                    }
                    if (button.BackColor == Color.Gray)
                    {
                        button.Text    = "";
                        button.Enabled = false;
                    }
                }
                timer.Stop();
                MyLibrary.WriteJson(difficulty, seconds, minesFound, CampoMinato.numero_mine, numberOfMoves, false);
                btnTornaMenu.Click -= new EventHandler(this.Form1_Load_Message_Box);
                btnTornaMenu.Click += new EventHandler(this.Form1_Load);
                Label lblSconfittaGiocatore = new Label();
                lblSconfittaGiocatore.Location  = new Point(36, 0);
                lblSconfittaGiocatore.Font      = new Font(Font.FontFamily, 14);
                lblSconfittaGiocatore.ForeColor = Color.White;
                lblSconfittaGiocatore.AutoSize  = true;
                lblSconfittaGiocatore.Text      = "Hai Perso! Mina trovata";
                this.Controls.Add(lblSconfittaGiocatore);
                break;

            default:
                NumeroCelleLiberate++;
                break;
            }
            if (MyLibrary.VerificaVittoria(CampoMinato.row, CampoMinato.col, CampoMinato.numero_mine, NumeroCelleLiberate))
            {
                timer.Stop();
                MyLibrary.WriteJson(difficulty, seconds, minesFound, CampoMinato.numero_mine, numberOfMoves, true);
                btnTornaMenu.Click -= new EventHandler(this.Form1_Load_Message_Box);
                btnTornaMenu.Click += new EventHandler(this.Form1_Load);
                Label lblVittoriaGiocatore = new Label();
                lblVittoriaGiocatore.Location  = new Point(36, 0);
                lblVittoriaGiocatore.Font      = new Font(Font.FontFamily, 14);
                lblVittoriaGiocatore.ForeColor = Color.White;
                lblVittoriaGiocatore.AutoSize  = true;
                lblVittoriaGiocatore.Text      = "Hai Vinto! Tutte le celle liberate!";
                foreach (Cella button in CampoMinato.ListBtnCelle)
                {
                    if (button.Text == "99")
                    {
                        button.Click    -= new EventHandler(btnCella_Click);
                        button.MouseUp  -= btnCella_MouseUp;
                        button.Text      = "";
                        button.Image     = Image.FromFile("../mina_bianca.gif");
                        button.ForeColor = Color.Black;
                        button.BackColor = Color.White;
                    }
                    if (button.BackColor == Color.Gray)
                    {
                        button.Text    = "";
                        button.Enabled = false;
                    }
                }
                this.Controls.Add(lblVittoriaGiocatore);
            }
        }