Наследование: System.Windows.Forms.Form, IListItemCheckColorSetter, IBenchmarkComunicator, IBenchmarkCalculation
Пример #1
0
        ///////////////////////////////////////
        // Miner control functions
        private bool StartMining(bool showWarnings)
        {
            if (textBoxBTCAddress.Text.Equals("")) {
                if (showWarnings) {
                    DialogResult result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"),
                                                      International.GetText("Form_Main_DemoModeTitle"),
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (result == System.Windows.Forms.DialogResult.Yes) {
                        DemoMode = true;
                        labelDemoMode.Visible = true;
                        labelDemoMode.Text = International.GetText("Form_Main_DemoModeLabel");
                    } else {
                        return false;
                    }
                } else {
                    return false;
                }
            } else if (!VerifyMiningAddress(true)) return false;

            if (Globals.NiceHashData == null) {
                if (showWarnings) {
                    MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"),
                                International.GetText("Error_with_Exclamation"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return false;
            }

            // Check if there are unbenchmakred algorithms
            bool isBenchInit = true;
            bool hasAnyAlgoEnabled = false;
            foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) {
                if (cdev.Enabled) {
                    foreach (var algo in cdev.AlgorithmSettings.Values) {
                        if (algo.Skip == false) {
                            hasAnyAlgoEnabled = true;
                            if (algo.BenchmarkSpeed == 0) {
                                isBenchInit = false;
                                break;
                            }
                        }
                    }
                }
            }
            // Check if the user has run benchmark first
            if (!isBenchInit) {
                DialogResult result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"),
                                                          International.GetText("Warning_with_Exclamation"),
                                                          MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                if (result == System.Windows.Forms.DialogResult.Yes) {
                    BenchmarkForm = new Form_Benchmark(
                        BenchmarkPerformanceType.Standard,
                        true);
                    SetChildFormCenter(BenchmarkForm);
                    BenchmarkForm.ShowDialog();
                    BenchmarkForm = null;
                    InitMainConfigGUIData();
                } else if (result == System.Windows.Forms.DialogResult.No) {
                    // check devices without benchmarks
                    foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) {
                        bool Enabled = false;
                        foreach (var algo in cdev.AlgorithmSettings) {
                            if (algo.Value.BenchmarkSpeed > 0) {
                                Enabled = true;
                                break;
                            }
                        }
                        cdev.Enabled = Enabled;
                    }
                } else {
                    return false;
                }
            }

            // check if any device enabled
            // check devices without benchmarks
            bool noDeviceEnabled = true;
            foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) {
                if (cdev.Enabled) {
                    noDeviceEnabled = false;
                    break;
                }
            }
            if (noDeviceEnabled) {
                if (showWarnings) {
                    DialogResult result = MessageBox.Show(International.GetText("Form_Main_No_Device_Enabled_For_Mining"),
                                                          International.GetText("Warning_with_Exclamation"),
                                                          MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                return false;
            }
            if (!hasAnyAlgoEnabled) {
                if (showWarnings) {
                    DialogResult result = MessageBox.Show(International.GetText("Form_Main_No_Device_Enabled_Algorithms_For_Mining"),
                                                          International.GetText("Warning_with_Exclamation"),
                                                          MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                return false;
            }

            textBoxBTCAddress.Enabled = false;
            textBoxWorkerName.Enabled = false;
            comboBoxLocation.Enabled = false;
            buttonBenchmark.Enabled = false;
            buttonStartMining.Enabled = false;
            buttonSettings.Enabled = false;
            devicesListViewEnableControl1.IsMining = true;
            buttonStopMining.Enabled = true;

            ConfigManager.GeneralConfig.BitcoinAddress = textBoxBTCAddress.Text.Trim();
            ConfigManager.GeneralConfig.WorkerName = textBoxWorkerName.Text.Trim();
            ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex;

            InitFlowPanelStart();
            ClearRatesALL();

            var btcAdress = DemoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim();
            var isMining = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex], textBoxWorkerName.Text.Trim(), btcAdress);

            if (!DemoMode) ConfigManager.GeneralConfigFileCommit();

            SMAMinerCheck.Interval = 100;
            SMAMinerCheck.Start();
            MinerStatsCheck.Start();

            return isMining;
        }
Пример #2
0
        private void buttonBenchmark_Click(object sender, EventArgs e)
        {
            ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex;

            BenchmarkForm = new Form_Benchmark();
            SetChildFormCenter(BenchmarkForm);
            BenchmarkForm.ShowDialog();
            bool startMining = BenchmarkForm.StartMining;
            BenchmarkForm = null;

            InitMainConfigGUIData();
            if (startMining) {
                buttonStartMining_Click(null, null);
            }
        }