public MinerConsole(CpuMinerData d)
        {
            this.data = d;
            Setup();

            Task.Factory.StartNew(() => { StartMiner(); });
        }
Esempio n. 2
0
        private void AddEditMiners_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            string strError = string.Empty;
            try
            {
                settings = settingsCall.GetSettings(ref strError);

                if (btn == btnAddEditCudaMiner)
                {
                    if (cbxDevice_CudaMiner.SelectedIndex == -1) //-1 means that there were no nvidia cards found
                        MessageBox.Show("It appears as if CUDA Admin could not find any nVidia video cards. You can try updating your drivers and/or restarting your PC.", "No Video Card Selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    else
                    {
                        //The only required fields are the pool address, the worker name, and the worker password
                        //A dark gray foreground means that no data has been entered because of the way the textbox logic works
                        if (txtPoolAddress_CudaMiner.ForeColor == Color.DarkGray || txtWorkerName_CudaMiner.ForeColor == Color.DarkGray || txtWorkerPassword_CudaMiner.ForeColor == Color.DarkGray)
                            UserMessage.ShowMessage(this, UserMessage.MessageType.Warning, "Please make enter valid information for the pool address, worker name, and the worker password");
                        else
                        {
                            GpuMinerData data = new GpuMinerData()
                            {
                                Name = txtName_CudaMiner.Text,
                                Retries = 3,
                                Active = false,
                                WorkerName = txtWorkerName_CudaMiner.Text,
                                WorkerPassword = txtWorkerPassword_CudaMiner.Text,
                                PoolAddress = txtPoolAddress_CudaMiner.Text,
                                Device = cbxDevice_CudaMiner.SelectedIndex,
                                Algorithm = cbxAlgorithm_CudaMiner.Text,
                                Kernel = cbxKernel_CudaMiner.Text,
                                CpuAssist = cbxCpuAssist_CudaMiner.Text,
                                TextureCache = cbxTextureCache_CudaMiner.Text,
                                LookupGap = Convert.ToInt32(txtLookupGap_CudaMiner.Text),
                                Batchsize = Convert.ToInt32(txtBatchsize_CudaMiner.Text),
                                Interactive = chkInteractive_CudaMiner.Checked,
                                SingleMemory = chkSingleMemory_CudaMiner.Checked,
                                Debug = chkDebug_CudaMiner.Checked,
                                CommandLine = GetCommandLineString(Miner.GPU)
                            };

                            if (minerType == Type.Edit)
                            {
                                //Get the index of the item to be edited
                                int index = (from GpuMinerData miner in settings.GpuMiners
                                             where miner.MinerGUID == minerGuid
                                             select settings.GpuMiners.IndexOf(miner)).First();
                                //Replace that item
                                settings.GpuMiners[index] = data;
                            }
                            else if (minerType == Type.Add)
                            {
                                settings.GpuMiners.Add(data); //Add the miner to the settings list
                            }

                            settingsCall.SeriliazeSettings(settings); //Serialize all the settings
                            Application.OpenForms.OfType<frmMain>().Single(x => x.Name == "frmMain").AddMinersToDataGridViews(true);

                            this.Close();
                        }
                    }
                }
                else if (btn == btnAddEditCpuMiner)
                {
                    if (txtPoolAddress_CpuMiner.ForeColor == Color.DarkGray || txtWorkerName_CpuMiner.ForeColor == Color.DarkGray || txtWorkerPassword_CpuMiner.ForeColor == Color.DarkGray)
                        UserMessage.ShowMessage(this, UserMessage.MessageType.Warning, "Please make enter valid information for the pool address, worker name, and the worker password");
                    else
                    {
                        CpuMinerData data = new CpuMinerData()
                        {
                            Name = txtName_CpuMiner.Text,
                            Retries = 3,
                            WorkerName = txtWorkerName_CpuMiner.Text,
                            WorkerPassword = txtWorkerPassword_CpuMiner.Text,
                            Active = false,
                            CommandLine = GetCommandLineString(Miner.CPU),
                            LongPoll = chkLongPoll_CpuMiner.Checked,
                            Stratum = chkNoStratum_CpuMiner.Checked,
                            PoolAddress = txtPoolAddress_CpuMiner.Text,
                            Debug = chkDebug_CpuMiner.Checked
                        };
                        if (minerType == Type.Edit)
                        {
                            //Get the index of the item to be edited
                            int index = (from CpuMinerData miner in settings.CpuMiners
                                         where miner.MinerGUID == minerGuid
                                         select settings.CpuMiners.IndexOf(miner)).First();
                            //Replace that item
                            settings.CpuMiners[index] = data;
                        }
                        else if (minerType == Type.Add)
                        {
                            settings.CpuMiners.Add(data); //Add the miner to the settings list
                        }

                        settingsCall.SeriliazeSettings(settings); //Serialize all the settings
                        Application.OpenForms.OfType<frmMain>().Single(x => x.Name == "frmMain").AddMinersToDataGridViews(true);

                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                UserMessage.ShowMessage(this, UserMessage.MessageType.Error, "An error occurred while trying to add that miner. Error: " + ex.Message);
            }
        }