Exemple #1
0
        private void CombineButton_Click(object sender, EventArgs e)
        {
            if (this.asyncWaiting)
            {
                return;                 // there was already a thread waiting for hotkey
            }

            while (GetAsyncKeyState((Keys)Settings.Default.Hotkey) != 0)
            {
                // MessageBox.Show("Key detection failed, or you were already holding hotkey. Try again.");
                Thread.Sleep(200);
            }

            this.combineButton.Text = "Press " + SettingsHandler.HotkeyText + " on A1";             // hotkey
            this.asyncWaiting       = true;
            do
            {
                Application.DoEvents();
                Thread.Sleep(10);

                // [HR] Cancel before starting or if form is closing
                if (GetAsyncKeyState(Keys.Escape) != 0 || !CombinePerformer.Enabled)
                {
                    this.combineButton.Text = "Combine";
                    this.asyncWaiting       = false;
                    return;
                }
            }while (GetAsyncKeyState((Keys)Settings.Default.Hotkey) == 0 || Control.ModifierKeys != Keys.None);

            // User pressed hotkey
            this.asyncWaiting          = false;
            CombinePerformer.SleepTime = (int)this.delayNumeric.Value;
            this.stopwatch.Reset();
            this.stopwatch.Start();
            this.combineProgressBar.Maximum = CombinePerformer.Instructions.Count;
            // Don't combine if recipe is a simple g1
            if (this.stepNumeric.Value > 0)
            {
                CombinePerformer.PerformCombine((int)this.stepNumeric.Value);
            }

            // Combine finished
            this.combineProgressBar.Value = this.combineProgressBar.Minimum;
            this.GuessEta();
            this.combineButton.Text = "Combine";
            if (Settings.Default.AutoCombine)
            {
                this.combineButton.PerformClick();                 // guess it's finished, click the "combine" again
            }
        }