Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!VerifyMiningAddress(true))
            {
                return;
            }

            if (NiceHashData == null)
            {
                MessageBox.Show("Unable to get NiceHash profitability data. If you are connected to internet, try again later.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check if the user has run benchmark first
            foreach (Miner m in Miners)
            {
                if (m.EnabledDeviceCount() == 0)
                {
                    continue;
                }

                if (m.CountBenchmarkedAlgos() == 0)
                {
                    DialogResult result = MessageBox.Show("You have not yet run the benchmark for device " + m.MinerDeviceName + ". " +
                                                          "Without running the benchmark, NiceHashMiner will not be able to switch to " +
                                                          "the most profitable algo. To continue mining, choose Yes. If you wish to benchmark " +
                                                          "first, choose No and click on the benchmark button.", "Error!",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        break;
                    }
                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }
                }
            }

            textBox1.Enabled  = false;
            textBox2.Enabled  = false;
            comboBox1.Enabled = false;
            button3.Enabled   = false;
            button1.Enabled   = false;
            button4.Enabled   = false;
            listView1.Enabled = false;
            button2.Enabled   = true;

            // todo: commit saving when values are changed
            Config.ConfigData.BitcoinAddress = textBox1.Text.Trim();
            Config.ConfigData.WorkerName     = textBox2.Text.Trim();
            Config.ConfigData.Location       = comboBox1.SelectedIndex;
            Config.Commit();

            SMAMinerCheck.Start();
            SMAMinerCheck_Tick(null, null);
            MinerStatsCheck.Start();
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!VerifyMiningAddress())
            {
                return;
            }

            if (NiceHashData == null)
            {
                MessageBox.Show("Unable to get NiceHash profitability data. If you are connected to internet, try again later.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            textBox1.Enabled  = false;
            textBox2.Enabled  = false;
            comboBox1.Enabled = false;
            button3.Enabled   = false;
            button1.Enabled   = false;
            button4.Enabled   = false;
            listView1.Enabled = false;
            button2.Enabled   = true;

            // todo: commit saving when values are changed
            Config.ConfigData.BitcoinAddress = textBox1.Text.Trim();
            Config.ConfigData.WorkerName     = textBox2.Text.Trim();
            Config.ConfigData.Location       = comboBox1.SelectedIndex;
            Config.Commit();

            SMAMinerCheck.Start();
            SMAMinerCheck_Tick(null, null);
            MinerStatsCheck.Start();
        }
Пример #3
0
 public static void RebuildGroups()
 {
     // rebuild config groups
     Group[] CG = new Group[Form1.Miners.Length];
     for (int i = 0; i < Form1.Miners.Length; i++)
     {
         CG[i]                       = new Group();
         CG[i].Name                  = Form1.Miners[i].MinerDeviceName;
         CG[i].APIBindPort           = Form1.Miners[i].APIPort;
         CG[i].ExtraLaunchParameters = Form1.Miners[i].ExtraLaunchParameters;
         CG[i].UsePassword           = Form1.Miners[i].UsePassword;
         CG[i].Algorithms            = new Algo[Form1.Miners[i].SupportedAlgorithms.Length];
         for (int k = 0; k < Form1.Miners[i].SupportedAlgorithms.Length; k++)
         {
             CG[i].Algorithms[k]                       = new Algo();
             CG[i].Algorithms[k].Name                  = Form1.Miners[i].SupportedAlgorithms[k].NiceHashName;
             CG[i].Algorithms[k].BenchmarkSpeed        = Form1.Miners[i].SupportedAlgorithms[k].BenchmarkSpeed;
             CG[i].Algorithms[k].ExtraLaunchParameters = Form1.Miners[i].SupportedAlgorithms[k].ExtraLaunchParameters;
             CG[i].Algorithms[k].UsePassword           = Form1.Miners[i].SupportedAlgorithms[k].UsePassword;
             CG[i].Algorithms[k].Skip                  = Form1.Miners[i].SupportedAlgorithms[k].Skip;
         }
         List <int> DD = new List <int>();
         for (int k = 0; k < Form1.Miners[i].CDevs.Count; k++)
         {
             if (!Form1.Miners[i].CDevs[k].Enabled)
             {
                 DD.Add(k);
             }
         }
         CG[i].DisabledDevices = DD.ToArray();
     }
     ConfigData.Groups = CG;
     Config.Commit();
 }
Пример #4
0
 private void textBox1_Leave(object sender, EventArgs e)
 {
     // Commit to config.json
     Config.ConfigData.BitcoinAddress = textBox1.Text.Trim();
     Config.ConfigData.WorkerName     = textBox2.Text.Trim();
     Config.ConfigData.Location       = comboBox1.SelectedIndex;
     Config.Commit();
 }
Пример #5
0
 private void textBoxCheckBoxMain_Leave(object sender, EventArgs e)
 {
     if (VerifyMiningAddress(false))
     {
         // Commit to config.json
         Config.ConfigData.BitcoinAddress  = textBoxBTCAddress.Text.Trim();
         Config.ConfigData.WorkerName      = textBoxWorkerName.Text.Trim();
         Config.ConfigData.ServiceLocation = comboBoxLocation.SelectedIndex;
         Config.Commit();
     }
 }
Пример #6
0
        public static void RebuildGroups()
        {
            // rebuild config groups
            Group[] CG = new Group[Globals.Miners.Length];
            for (int i = 0; i < Globals.Miners.Length; i++)
            {
                CG[i]                               = new Group();
                CG[i].Name                          = Globals.Miners[i].MinerDeviceName;
                CG[i].APIBindPort                   = Globals.Miners[i].APIPort;
                CG[i].ExtraLaunchParameters         = Globals.Miners[i].ExtraLaunchParameters;
                CG[i].UsePassword                   = Globals.Miners[i].UsePassword;
                CG[i].MinimumProfit                 = Globals.Miners[i].MinimumProfit;
                CG[i].DaggerHashimotoGenerateDevice = Globals.Miners[i].DaggerHashimotoGenerateDevice;
                CG[i].Algorithms                    = new Algo[Globals.Miners[i].SupportedAlgorithms.Length];
                for (int k = 0; k < Globals.Miners[i].SupportedAlgorithms.Length; k++)
                {
                    CG[i].Algorithms[k]                       = new Algo();
                    CG[i].Algorithms[k].Name                  = Globals.Miners[i].SupportedAlgorithms[k].NiceHashName;
                    CG[i].Algorithms[k].BenchmarkSpeed        = Globals.Miners[i].SupportedAlgorithms[k].BenchmarkSpeed;
                    CG[i].Algorithms[k].ExtraLaunchParameters = Globals.Miners[i].SupportedAlgorithms[k].ExtraLaunchParameters;
                    CG[i].Algorithms[k].UsePassword           = Globals.Miners[i].SupportedAlgorithms[k].UsePassword;
                    CG[i].Algorithms[k].Skip                  = Globals.Miners[i].SupportedAlgorithms[k].Skip;

                    CG[i].Algorithms[k].DisabledDevices = new bool[Globals.Miners[i].CDevs.Count];
                    for (int j = 0; j < Globals.Miners[i].CDevs.Count; j++)
                    {
                        // quickfix new algo add
                        if (Globals.Miners[i].SupportedAlgorithms[k].DisabledDevice == null)
                        {
                            bool[] newArray = new bool[Globals.Miners[i].CDevs.Count];
                            // init to false
                            for (int devIndex = 0; devIndex < newArray.Length; ++devIndex)
                            {
                                newArray[devIndex] = false;
                            }
                            Globals.Miners[i].SupportedAlgorithms[k].DisabledDevice = newArray;
                        }
                        CG[i].Algorithms[k].DisabledDevices[j] = Globals.Miners[i].SupportedAlgorithms[k].DisabledDevice[j];
                    }
                }
                List <int> DD = new List <int>();
                for (int k = 0; k < Globals.Miners[i].CDevs.Count; k++)
                {
                    if (!Globals.Miners[i].CDevs[k].Enabled)
                    {
                        DD.Add(k);
                    }
                }
                CG[i].DisabledDevices = DD.ToArray();
            }
            ConfigData.Groups = CG;
            Config.Commit();
        }
Пример #7
0
        private void buttonStopMining_Click(object sender, EventArgs e)
        {
            MinerStatsCheck.Stop();
            SMAMinerCheck.Stop();

            foreach (Miner m in Globals.Miners)
            {
                m.Stop(false);
                m.IsRunning   = false;
                m.CurrentAlgo = -1;
                m.CurrentRate = 0;
            }

            SetCPUStats("", 0, 0);
            SetNVIDIAtp21Stats("", 0, 0);
            SetNVIDIAspStats("", 0, 0);
            SetNVIDIAtpStats("", 0, 0);
            SetAMDOpenCLStats("", 0, 0);

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

            if (DemoMode)
            {
                DemoMode = false;
                labelDemoMode.Visible = false;

                textBoxBTCAddress.Text           = "";
                Config.ConfigData.BitcoinAddress = "";
                Config.Commit();
            }

            UpdateGlobalRate();
        }
Пример #8
0
        private void buttonStartMining_Click(object sender, EventArgs e)
        {
            if (textBoxBTCAddress.Text.Equals(""))
            {
                DialogResult result = MessageBox.Show(International.GetText("form1_DemoModeMsg"),
                                                      International.GetText("form1_DemoModeTitle"),
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    DemoMode = true;
                    labelDemoMode.Visible = true;
                    labelDemoMode.Text    = International.GetText("form1_DemoModeLabel");

                    textBoxBTCAddress.Text = "34HKWdzLxWBduUfJE9JxaFhoXnfC6gmePG";
                }
                else
                {
                    return;
                }
            }
            else if (!VerifyMiningAddress(true))
            {
                return;
            }

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

            // Check if the user has run benchmark first
            foreach (Miner m in Globals.Miners)
            {
                if (m.EnabledDeviceCount() == 0)
                {
                    continue;
                }

                if (m.CountBenchmarkedAlgos() == 0)
                {
                    DialogResult result = MessageBox.Show(String.Format(International.GetText("form1_msgbox_HaveNotBenchmarkedMsg"), m.MinerDeviceName),
                                                          International.GetText("Warning_with_Exclamation"),
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        if (!(m is cpuminer))
                        {
                            // quick and ugly way to prevent GPUs from starting on extremely unprofitable x11
                            m.SupportedAlgorithms[14].BenchmarkSpeed = 1;
                        }
                        break;
                    }
                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        DemoMode = false;
                        labelDemoMode.Visible = false;

                        textBoxBTCAddress.Text           = "";
                        Config.ConfigData.BitcoinAddress = "";
                        Config.Commit();

                        return;
                    }
                }
            }

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

            Config.ConfigData.BitcoinAddress  = textBoxBTCAddress.Text.Trim();
            Config.ConfigData.WorkerName      = textBoxWorkerName.Text.Trim();
            Config.ConfigData.ServiceLocation = comboBoxLocation.SelectedIndex;
            if (!DemoMode)
            {
                Config.Commit();
            }

            SMAMinerCheck.Interval = 100;
            SMAMinerCheck.Start();
            //SMAMinerCheck_Tick(null, null);
            MinerStatsCheck.Start();
        }
Пример #9
0
 private void Form_Settings_FormClosing(object sender, FormClosingEventArgs e)
 {
     Config.Commit();
 }