Ejemplo n.º 1
0
        // TODO this has nothing to do with Mian_Form
        private async void IdleCheck(object sender, IdleChangedEventArgs e)
        {
            if (!ConfigManager.GeneralConfig.StartMiningWhenIdle || _isManuallyStarted)
            {
                return;
            }

            // TODO set is mining here
            if (MiningState.Instance.IsCurrentlyMining)
            {
                if (!e.IsIdle)
                {
                    await ApplicationStateManager.StopAllDevice();

                    Logger.Info("NICEHASH", "Resumed from idling");
                }
            }
            else if (ApplicationStateManager.CurrentForm == ApplicationStateManager.CurrentFormState.Main && e.IsIdle)
            {
                Logger.Info("NICEHASH", "Entering idling state");
                if (StartMining(false) != StartMiningReturnType.StartMining)
                {
                    await ApplicationStateManager.StopAllDevice();
                }
            }
        }
Ejemplo n.º 2
0
        private async void Form_Main_Shown(object sender, EventArgs e)
        {
            //// TODO temporary hooks
            ApplicationStateManager._ratesComunication = devicesListViewEnableControl1;
            // handle these callbacks differently
            //NiceHashStats.OnConnectionLost += ConnectionLostCallback;
            ApplicationStateManager.OnExchangeUpdate += UpdateExchange;

            foreach (Control c in Controls)
            {
                c.Enabled = false;
            }

            using (var loadingControl = new StartupLoadingControl(Tr("Loading, please wait...")))
            {
                Controls.Add(loadingControl);
                var location = new Point((Width - loadingControl.Width) / 2, (int)((Height - loadingControl.Height) * 0.3));
                loadingControl.Location = location;
                loadingControl.BringToFront();

                var progress = new Progress <(string loadMessageText, int perc)>(p =>
                {
                    loadingControl.Progress        = (int)p.perc;
                    loadingControl.LoadMessageText = p.loadMessageText;
                });

                var progressDownload = new Progress <(string loadMessageText, int perc)>(p =>
                {
                    loadingControl.ProgressSecond        = (int)p.perc;
                    loadingControl.LoadMessageTextSecond = p.loadMessageText;
                });
                await ApplicationStateManager.InitializeManagersAndMiners(loadingControl);
            }
            devicesListViewEnableControl1.SetComputeDevices(AvailableDevices.Devices.ToList());

            foreach (Control c in Controls)
            {
                c.Enabled = true;
            }

            // Data bindings
            InitDataBindings();
            textBoxBTCAddress_Validate();
            textBoxWorkerName_Validate();

            if (ConfigManager.GeneralConfig.AutoStartMining)
            {
                // well this is started manually as we want it to start at runtime
                _isManuallyStarted = true;
                if (StartMining(false) != StartMiningReturnType.StartMining)
                {
                    _isManuallyStarted = false;
                    ApplicationStateManager.StopAllDevice();
                }
            }
#if SHOW_TDP_SETTINGS
            var form_TDP = new Form_TDPSettings();
            form_TDP.Show();
#endif
        }
Ejemplo n.º 3
0
 private void ButtonStartMining_Click(object sender, EventArgs e)
 {
     _isManuallyStarted = true;
     if (StartMining(true) == StartMiningReturnType.ShowNoMining)
     {
         _isManuallyStarted = false;
         ApplicationStateManager.StopAllDevice();
         MessageBox.Show(Tr("NiceHash Miner Legacy cannot start mining. Make sure you have at least one enabled device that has at least one enabled and benchmarked algorithm."),
                         Tr("Warning!"),
                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Ejemplo n.º 4
0
 private async void ButtonStopMining_Click(object sender, EventArgs e)
 {
     _isManuallyStarted = false;
     await ApplicationStateManager.StopAllDevice();
 }