Example #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            string strError = string.Empty;

            ScheduleTask.CreateNewTask();
            //ScheduleTask.RunTask();

            //Initialize Calls and data
            settingsCall = new SettingCall();
            settings = new Settings();
            devices = new DevicesCall();
            comp = new Computer();
            miner = new MinerCall();

            if (miner.IsMinersRunning())
                if (MessageBox.Show("CUDA Administrator detected that there are CPU or GPU miners already running. Do you want to shutdown these miners now?",
                    "Miners Running", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    miner.ShutdownMiners();

            bool isNewVersion = settingsCall.IsNewVersionAvailable(ref strError);
            if (!string.IsNullOrEmpty(strError))
            {
                UserMessage.ShowMessage(this, UserMessage.MessageType.Error, "There was an error while trying to check for the latest version of CUDA Administrator. Error: " + strError);
                strError = string.Empty;
            }
            else
            {
                if (isNewVersion)
                    if (MessageBox.Show("A new version of CUDA Administrator is available. Would you like to go to the subreddit?", "Verion Check", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                        Process.Start("http://www.reddit.com/r/CudaAdministrator");
            }

            this.Icon = settingsCall.GetApplicationIcon();

            comp.Open();
            comp.CPUEnabled = true;

            //Set UI data
            AddMinersToDataGridViews();

            //Setup everything required to run CUDA Admin
            settingsCall.CreateFolders(ref strError);
            if (!string.IsNullOrEmpty(strError))
            {
                MessageBox.Show(strError, "Folder Creation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(Environment.ExitCode);
            }

            if (!File.Exists(FileManager.CudaMinerPath + "cudaminer.exe") || !File.Exists(FileManager.CudaMinerPath + "pthreadVC2.dll") || !(File.Exists(FileManager.CudaMinerPath + "cudart64_55.dll") || File.Exists(FileManager.CudaMinerPath + "cudart32_55.dll")))
                UserMessage.ShowMessage(this, UserMessage.MessageType.Warning, "GPU Miner disabled. Either it or some/all of it's dependencies couldn't be located");
            if (!File.Exists(FileManager.CpuMinerPath + "minerd.exe") || !File.Exists(FileManager.CpuMinerPath + "libwinpthread-1.dll") || !(File.Exists(FileManager.CpuMinerPath + "libcurl.dll") || File.Exists(FileManager.CpuMinerPath + "libcurl-4.dll")))
                UserMessage.ShowMessage(this, UserMessage.MessageType.Warning, "CPU Miner disabled. Either it or some/all of it's dependencies couldn't be located");

            settings = settingsCall.GetSettings(ref strError);
            if (!string.IsNullOrEmpty(strError))
                UserMessage.ShowMessage(this, UserMessage.MessageType.Error, "An error occurred while trying to get the settings data. Error: " + strError);

            string[] args = Environment.GetCommandLineArgs();
            if (args.Contains("--autorun"))
                btnMinerAutomation.PerformClick();
        }
Example #2
0
        public frmMiner(Type type, Miner miner = Miner.GPU, Guid guid = default(Guid))
        {
            InitializeComponent();
            string strError = string.Empty;

            SetTips();

            devices = new DevicesCall();
            settingsCall = new SettingCall();

            settings = settingsCall.GetSettings(ref strError);
            this.Icon = settingsCall.GetApplicationIcon();

            AddVideoCardsToComboBox();
            ResetAddMinerFields(Miner.GPU);
            ResetAddMinerFields(Miner.CPU);
            cbxMiner.SelectedIndex = 0; //Default to GPU
            minerType = type;
            minerGuid = guid;

            if (type == Type.Add)
            {
                this.Text = "Add Miner";
                btnAddEditCpuMiner.Text = "Add";
            }
            else if (type == Type.Edit)
            {
                if (guid == default(Guid))
                    MessageBox.Show("The user should never see this message.\r\n\r\nEdit was selected, but no GUID was passed.", "Err...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                {
                    if (Debugger.IsAttached)
                        lblOldGuid.Visible = true;

                    txtName_CudaMiner.ForeColor = Color.Black;
                    txtPoolAddress_CudaMiner.ForeColor = Color.Black;
                    txtWorkerName_CudaMiner.ForeColor = Color.Black;
                    txtWorkerPassword_CudaMiner.ForeColor = Color.Black;

                    txtName_CpuMiner.ForeColor = Color.Black;
                    txtPoolAddress_CpuMiner.ForeColor = Color.Black;
                    txtWorkerName_CpuMiner.ForeColor = Color.Black;
                    txtWorkerPassword_CpuMiner.ForeColor = Color.Black;

                    if (miner == Miner.GPU)
                    {
                        tcMiners.SelectedIndex = 0;
                        cbxMiner.SelectedIndex = 0;
                        btnAddEditCudaMiner.Text = "Edit Miner";

                        GpuMinerData selectedMiner = settings.GpuMiners.SingleOrDefault(x => x.MinerGUID == guid);
                        txtName_CudaMiner.Text = selectedMiner.Name;
                        txtPoolAddress_CudaMiner.Text = selectedMiner.PoolAddress;
                        txtWorkerName_CudaMiner.Text = selectedMiner.WorkerName;
                        txtWorkerPassword_CudaMiner.Text = selectedMiner.WorkerPassword;
                        cbxDevice_CudaMiner.SelectedIndex = selectedMiner.Device;
                        cbxAlgorithm_CudaMiner.Text = selectedMiner.Algorithm;
                        cbxCpuAssist_CudaMiner.Text = selectedMiner.CpuAssist;
                        cbxTextureCache_CudaMiner.Text = selectedMiner.TextureCache;
                        txtLookupGap_CudaMiner.Text = selectedMiner.LookupGap.ToString();
                        txtBatchsize_CudaMiner.Text = selectedMiner.Batchsize.ToString();
                        chkInteractive_CudaMiner.Checked = selectedMiner.Interactive;
                        chkSingleMemory_CudaMiner.Checked = selectedMiner.SingleMemory;
                        chkDebug_CudaMiner.Checked = selectedMiner.Debug;
                    }
                    else if (miner == Miner.CPU)
                    {
                        tcMiners.SelectedIndex = 1;
                        cbxMiner.SelectedIndex = 1;
                        btnAddEditCpuMiner.Text = "Edit Miner";

                        CpuMinerData selectedMiner = settings.CpuMiners.SingleOrDefault(x => x.MinerGUID == guid);
                        txtName_CpuMiner.Text = selectedMiner.Name;
                        txtPoolAddress_CpuMiner.Text = selectedMiner.PoolAddress;
                        txtWorkerName_CpuMiner.Text = selectedMiner.WorkerName;
                        txtWorkerPassword_CpuMiner.Text = selectedMiner.WorkerPassword;
                    }

                    cbxMiner.Enabled = false;

                    this.Text = "Edit Miner";
                    btnAddEditCpuMiner.Text = "Edit";

                    lblOldGuid.Text = guid.ToString().ToUpper();
                }
            }
        }