Exemplo n.º 1
0
        public frmDonate()
        {
            InitializeComponent();

            settingsCall = new SettingCall();
            this.Icon = settingsCall.GetApplicationIcon();
        }
        public void RefreshCard(VideoCard card)
        {
            string strError = string.Empty;
            SettingCall settingsCall = new SettingCall();
            Settings settings = settingsCall.GetSettings(ref strError); ;

            nvidiaCard = card;

            int temp = Convert.ToInt32(card.TemperatureSensors[0].Value);
            Color clr = Color.White;
            if (temp < 70)
                clr = Color.Green;
            else if (temp >= 70 && temp < 90)
                clr = Color.Orange;
            else if (temp >= 90)
                clr = Color.Red;

            lblNumber.Text = card.Number.ToString();
            lblName.Text = card.Name;
            lblTemp.Text = card.TemperatureSensors[0].Value.ToString() + "°C";
            lblClockSpeed.Text = Convert.ToInt32(card.ClockSensors[0].Value).ToString() + " MHz";

            lblTemp.ForeColor = clr;

            if (!cbxFanSpeed.DroppedDown) //We don't want to add the fan % if this is dropped down because then the user will have a hard time selecting a new value
                cbxFanSpeed.Text = card.FanSensors[0].Value.ToString() + "%";

            if (settings.Options.IsTempProtectionActivated)
            {
                if (TemperatureRun > 0)
                    TemperatureRun++;

                if (card.TemperatureSensors[0].Value >= settings.Options.TemperatureMax && !IsCoolingDown)
                {
                    SendNotificationToTray("Temperature Protection", "Temperature threshold reached. The Fan will run at 100% for 3 minutes and then run at 50%.");
                    nvidiaCard.FanSensors[0].Control.SetSoftware(100);
                    IsCoolingDown = true;
                }
                else if (!settings.Options.IsTempProtectionActivated || card.TemperatureSensors[0].Value < settings.Options.TemperatureMax && TemperatureRun >= 180)  //180 = 3 minutes. Let the fan run for 3 minutes
                {
                    IsCoolingDown = false;
                    TemperatureRun = 0;
                    nvidiaCard.FanSensors[0].Control.SetSoftware(50);
                }
            }
        }
Exemplo n.º 3
0
        private void frmOptions_Load(object sender, EventArgs e)
        {
            string strError = string.Empty;

            settingsCall = new SettingCall();
            optionsCall = new OptionsCall();
            settings = settingsCall.GetSettings(ref strError);

            this.Icon = settingsCall.GetApplicationIcon();

            if (!string.IsNullOrEmpty(strError))
                MessageBox.Show("An error occurred while trying to get the settings file data.\r\n\r\n" + strError);

            chkRunOnStartup.Checked = settings.Options.IsRunningOnStartup;
            intActivateProtection.Value = settings.Options.TemperatureMax;
            intShutdownMiners.Value = settings.Options.TemperatureShutdown;

            chkEnableTempProtection.Checked = settings.Options.IsTempProtectionActivated;
            pnlTempProtectionSettings.Enabled = chkEnableTempProtection.Checked;

            chkContinuousMinerLogging.Checked = settings.Options.IsContinuousMinerLogging;
        }
Exemplo n.º 4
0
        private void MinerAutomation_Click(object sender, EventArgs e)
        {
            //When users change the values, they have to commit the edits by hitting return or F2
            //But that's not dependable. So we'll commit the edits for them, just in case they don't
            dgvMiners.EndEdit();

            string message = string.Empty;
            if (!IsMinerSetupValid(ref message))
            {
                UserMessage.ShowMessage(this, UserMessage.MessageType.Error, message);
                return;
            }

            gbxMiners.Enabled = false;
            if (btnMinerAutomation.Tag.ToString() == "STOP")
            {
                string strError = string.Empty;
                SettingCall call = new SettingCall();

                SaveMinerSettings(ref strError); //Save settings here so we can just use the Settings object and pass it to the control and not have mismatched data
                if (!string.IsNullOrEmpty(strError))
                {
                    UserMessage.ShowMessage(this, UserMessage.MessageType.Error, "The miners couldn't start because the settings couldn't be saved. Error: " + strError);
                    return;
                }

                settings = settingsCall.GetSettings(ref strError);
                if (!string.IsNullOrEmpty(strError))
                {
                    UserMessage.ShowMessage(this, UserMessage.MessageType.Error, "The miners couldn't start because the settings couldn't be retrieved. Error: " + strError);
                    return;
                }

                if (settings.GpuMiners.Count == 0 && settings.CpuMiners.Count == 0)
                {
                    UserMessage.ShowMessage(this, UserMessage.MessageType.Warning, "There are no miners");
                    return;
                }

                btnMinerAutomation.Tag = "START";
                btnMinerAutomation.Image = Properties.Resources.stop;
                tcMinerConsoles.TabPages.Clear();

                foreach (GpuMinerData gpu in settings.GpuMiners)
                {
                    if (gpu.Active)
                    {
                        MinerConsole console = new MinerConsole(gpu);
                        console.Text = "GPU Miner - " + gpu.Name;

                        tcMinerConsoles.TabPages.Add(console);
                    }
                }
                foreach (CpuMinerData cpu in settings.CpuMiners)
                {
                    if (cpu.Active)
                    {
                        MinerConsole console = new MinerConsole(cpu);
                        console.Text = "CPU Miner - " + cpu.Name;

                        tcMinerConsoles.TabPages.Add(console);
                    }
                }
            }
            else if (btnMinerAutomation.Tag.ToString() == "START")
            {
                if (MessageBox.Show("Are you sure you want to stop all miners?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    string strError = string.Empty;

                    foreach (TabPage page in tcMinerConsoles.TabPages)
                    {
                        if (page is MinerConsole)
                        {
                            MinerConsole console = page as MinerConsole;
                            console.StopMiner("Operation stopped by user", ref strError);

                            if (!string.IsNullOrEmpty(strError))
                                UserMessage.ShowMessage(this, UserMessage.MessageType.Error, "An error occurred while trying to stop the miner for " + page.Text.Replace("GPU Miner - ", "").Replace("CPU Miner - ", "") + ". Error: " + strError);
                        }
                    }

                    btnMinerAutomation.Tag = "STOP";
                    btnMinerAutomation.Image = Properties.Resources.start;
                    gbxMiners.Enabled = true;
                }
            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        private void Setup()
        {
            InitializeComponent();
            string strError = string.Empty;

            settingsCall = new SettingCall();
            settings = settingsCall.GetSettings(ref strError);

            flpStatus = new FlowLayoutPanel() { Dock = DockStyle.Top, Height = 20, BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle };
            lblPipe = new Label() { Text = "|", AutoSize = true, Margin = new Padding(0, 2, 0, 0) };
            lblAvgHashrate = new Label() { Text = "Avg. Hashrate: 0 kh/s", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            lblRuntime = new Label() { Text = "Run Time: 00:00:00", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            txtConsole = new RichTextBox() { Dock = DockStyle.Fill, ReadOnly = true, BackColor = SystemColors.Control, ForeColor = SystemColors.WindowText, Multiline = true, Height = this.Height, BorderStyle = BorderStyle.FixedSingle };
            lblAccepts = new Label() { Text = "Accepts: 0/min", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            lblKernel = new Label() { Text = "Kernel: N/A", Margin = new Padding(0, 2, 0, 0), AutoSize = true };
            lblGUID = new Label() { Text = "GUID: ", Margin = new Padding(0, 2, 0, 0), AutoSize = true, ForeColor = Color.Gray };

            flpStatus.Controls.Add(lblAvgHashrate);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblRuntime);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblAccepts);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblKernel);
            flpStatus.Controls.Add(lblPipe); //Separator
            flpStatus.Controls.Add(lblGUID);

            this.Controls.Add(flpStatus);
            this.Controls.Add(txtConsole);

            watch = new Stopwatch();
            watch.Start();
        }
Exemplo n.º 7
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();
                }
            }
        }
 private void SendNotificationToTray(string title, string message)
 {
     SettingCall settingsCall = new SettingCall();
     notifyTray.BalloonTipTitle = title;
     notifyTray.BalloonTipText = message;
     notifyTray.Icon = settingsCall.GetApplicationIcon(); ;
     notifyTray.ShowBalloonTip(5000);
 }