Exemple #1
0
        private void tmrTimeUpdate_Tick(object sender, EventArgs e)
        {
            if (_engine.ExitTime.HasValue && DateTime.Now >= _engine.ExitTime)
            {
                Application.Exit();
            }

            UpdateTimes();

            if (_engine.PricesUpdated)
            {
                UpdateGrid();

                if (_engine.ShowHistory)
                {
                    HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;
                    historyChart?.UpdateChart(_engine.StatWindow, 3);
                    _totalHistoryForm?.UpdateChart();
                }

                _engine.PricesUpdated = false;
            }

            MiningModeEnum[] autoModes = { MiningModeEnum.Automatic, MiningModeEnum.Donation };
            if (!autoModes.Contains(_engine.MiningMode))
            {
                return;
            }

            RunBestAlgo();
        }
        private void tmrTimeUpdate_Tick(object sender, EventArgs e)
        {
            if (_engine.ExitTime.HasValue && DateTime.Now >= _engine.ExitTime)
            {
                Application.Exit();
            }

            UpdateTimes();

            if (_engine.PricesUpdated)
            {
                UpdateGrid();

                HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;
                if (historyChart != null)
                {
                    historyChart.UpdateChart(TimeSpan.FromMinutes(20), 3);
                }
                if (_totalHistoryForm != null)
                {
                    _totalHistoryForm.UpdateChart();
                }

                _engine.PricesUpdated = false;
            }

            MiningModeEnum[] autoModes = { MiningModeEnum.Automatic, MiningModeEnum.Donation };
            if (!autoModes.Contains(_engine.MiningMode))
            {
                return;
            }

            RunBestAlgo();
        }
        private void MainWindow_Shown(object sender, EventArgs e)
        {
            // speeds up data grid view performance.
            typeof(DataGridView).InvokeMember("DoubleBuffered",
                                              BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, dgPrices,
                                              new object[] { true });
            typeof(DataGridView).InvokeMember("DoubleBuffered",
                                              BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, dgServices,
                                              new object[] { true });

            dgServices.AutoGenerateColumns = false;
            dgServices.DataSource          = new SortableBindingList <IService>(_engine.Services);

            dgPrices.AutoGenerateColumns = false;
            dgPrices.DataSource          = new SortableBindingList <PriceEntryBase>(_engine.PriceEntries);

            if (!_engine.DoDonationMinging)
            {
                textDonationStart.Enabled = false;
                textDonationEnd.Enabled   = false;
            }

            lblCurrencySymbol.Text = string.Empty; // Avoid flashing template value when starting

            if (!_engine.RemoteReceive)
            {
                tabPage.TabPages.Remove(tabRemote);
            }

            UpdateButtons();
            RunCycle();
            UpdateGrid(true);

            if (Program.MinimizeOnStart)
            {
                MinimizeWindow();
            }

            tmrPriceCheck.Enabled = true;
            if (!string.IsNullOrWhiteSpace(_engine.CurrencyCode))
            {
                tmrExchangeUpdate.Enabled = true;
            }
            if (Program.HasAutoStart)
            {
                _engine.MiningMode = MiningModeEnum.Automatic;
                UpdateButtons();
                RunBestAlgo();
            }

            HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;

            if (historyChart != null)
            {
                historyChart.History = _engine.PriceHistories;
                historyChart.FlipLegend();
                historyChart.UpdateChart(_engine.StatWindow);
                historyChart.Chart.DoubleClick += ChartOnDoubleClick;
            }
        }
        private void btnReloadConfig_Click(object sender, EventArgs e)
        {
            MiningModeEnum originalMode = _engine.MiningMode;
            ServiceEnum    service      = ServiceEnum.Manual;
            string         algo         = string.Empty;

            if (_engine.CurrentPriceEntry != null)
            {
                service = _engine.CurrentPriceEntry.ServiceEntry.ServiceEnum;
                algo    = _engine.CurrentPriceEntry.AlgoName;
            }

            _engine.Cleanup();
            _engine = new MiningEngine
            {
                WriteConsoleAction = WriteConsole,
                WriteRemoteAction  = WriteRemote
            };

            if (!_engine.LoadConfig())
            {
                MessageBox.Show("Something went wrong with reloading your configuration file. Check for errors.",
                                "Error loading conf", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            dgServices.DataSource = new SortableBindingList <IService>(_engine.Services);
            dgPrices.DataSource   = new SortableBindingList <PriceEntryBase>(_engine.PriceEntries);

            _engine.MiningMode = originalMode;

            _engine.LoadExchangeRates();
            RunCycle();
            UpdateButtons();
            UpdateGrid();

            HistoryChart historyChart = tabHistory.Controls["historyChart"] as HistoryChart;

            if (historyChart != null)
            {
                historyChart.UpdateChart();
            }

            if (originalMode == MiningModeEnum.Manual)
            {
                _engine.RequestStart(service, algo, IsMinimizedToTray);
            }
        }
Exemple #5
0
        private void InitHistoryChart()
        {
            HistoryChart preChart = tabHistory.Controls["historyChart"] as HistoryChart;

            if (preChart != null)
            {
                HistoryChart historyChart = new HistoryChart
                {
                    Dock    = DockStyle.Fill,
                    History = _engine.PriceHistories
                };

                historyChart.FlipLegend();
                historyChart.UpdateChart(_engine.StatWindow, 3);
                historyChart.Chart.DoubleClick += ChartOnDoubleClick;
                tabHistory.Controls.Remove(preChart);
                tabHistory.Controls.Add(historyChart);
            }
        }