public MinerFileNotFoundDialog(string MinerDeviceName, string Path) { InitializeComponent(); DisableDetection = false; Text = International.GetText("MinerFileNotFoundDialog_title"); linkLabelError.Text = String.Format(International.GetText("MinerFileNotFoundDialog_linkLabelError"), MinerDeviceName, Path, International.GetText("MinerFileNotFoundDialog_link")); linkLabelError.LinkArea = new LinkArea(linkLabelError.Text.IndexOf(International.GetText("MinerFileNotFoundDialog_link")), International.GetText("MinerFileNotFoundDialog_link").Length); chkBoxDisableDetection.Text = International.GetText("MinerFileNotFoundDialog_chkBoxDisableDetection"); buttonOK.Text = International.GetText("Global_OK"); }
public void SetBenchmarkPending() { IsBenchmarkPending = true; BenchmarkStatus = International.GetText("Algorithm_Waiting_Benchmark"); }
protected virtual string GetFinalBenchmarkString() { return(BenchmarkSignalTimedout ? International.GetText("Benchmark_Timedout") : International.GetText("Benchmark_Terminated")); }
private static void Main(string[] argv) { // Set working directory to exe Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; //Console.OutputEncoding = System.Text.Encoding.Unicode; // #0 set this first so data parsing will work correctly Globals.JsonSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore, Culture = CultureInfo.InvariantCulture }; // #1 first initialize config ConfigManager.InitializeConfig(); // #2 check if multiple instances are allowed bool startProgram = true; if (ConfigManager.GeneralConfig.AllowMultipleInstances == false) { try { Process current = Process.GetCurrentProcess(); foreach (Process process in Process.GetProcessesByName(current.ProcessName)) { if (process.Id != current.Id) { startProgram = false; } } } catch { } } if (startProgram) { if (ConfigManager.GeneralConfig.LogToFile) { Logger.ConfigureWithFile(); } if (ConfigManager.GeneralConfig.DebugConsole) { Helpers.AllocConsole(); } // init active display currency after config load ExchangeRateAPI.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; // #2 then parse args var commandLineArgs = new CommandLineParser(argv); Helpers.ConsolePrint("NICEHASH", "Starting up zPoolMiner v" + Application.ProductVersion); bool tosChecked = ConfigManager.GeneralConfig.agreedWithTOS == Globals.CURRENT_TOS_VER; if (!tosChecked || !ConfigManager.GeneralConfigIsFileExist() && !commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "No config file found. Running zPool Miner for the first time. Choosing a default language."); Application.Run(new Form_ChooseLanguage()); } // Init languages International.Initialize(ConfigManager.GeneralConfig.Language); if (commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "Language is overwritten by command line parameter (-lang)."); International.Initialize(commandLineArgs.LangValue); ConfigManager.GeneralConfig.Language = commandLineArgs.LangValue; } if (argv.Any(a => a == "--disable-donation")) { Miner.DonationStart = DateTime.MaxValue; } // check WMI if (Helpers.IsWMIEnabled()) { if (ConfigManager.GeneralConfig.agreedWithTOS == Globals.CURRENT_TOS_VER) { Application.Run(new Form_Main()); } } else { MessageBox.Show(International.GetText("Program_WMI_Error_Text"), International.GetText("Program_WMI_Error_Title"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private string FormatPayingOutput(double paying) { string ret = ""; if (ConfigManager.GeneralConfig.AutoScaleBTCValues && paying < 0.1) { ret = (paying * 1000 * factorTimeUnit).ToString("F5", CultureInfo.InvariantCulture) + " mBTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); } else { ret = (paying * factorTimeUnit).ToString("F6", CultureInfo.InvariantCulture) + " BTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); } return(ret); }
private StartMiningReturnType StartMining(bool showWarnings) { if (textBoxBTCAddress.Text.Equals("")) { if (showWarnings) { DialogResult result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"), International.GetText("Form_Main_DemoModeTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { DemoMode = true; labelDemoMode.Visible = true; labelDemoMode.Text = International.GetText("Form_Main_DemoModeLabel"); } else { return(StartMiningReturnType.IgnoreMsg); } } else { return(StartMiningReturnType.IgnoreMsg);; } } else if (!VerifyMiningAddress(true)) { return(StartMiningReturnType.IgnoreMsg); } if (Globals.NiceHashData == null) { if (showWarnings) { MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"), International.GetText("Error_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Error); } return(StartMiningReturnType.IgnoreMsg); } // Check if there are unbenchmakred algorithms bool isBenchInit = true; bool hasAnyAlgoEnabled = false; foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { if (cdev.Enabled) { foreach (var algo in cdev.GetAlgorithmSettings()) { if (algo.Enabled == true) { hasAnyAlgoEnabled = true; if (algo.BenchmarkSpeed == 0) { isBenchInit = false; break; } } } } } // Check if the user has run benchmark first if (!isBenchInit) { DialogResult result = DialogResult.No; if (showWarnings) { result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); } if (result == System.Windows.Forms.DialogResult.Yes) { BenchmarkForm = new Form_Benchmark( BenchmarkPerformanceType.Standard, true); SetChildFormCenter(BenchmarkForm); BenchmarkForm.ShowDialog(); BenchmarkForm = null; InitMainConfigGUIData(); } else if (result == System.Windows.Forms.DialogResult.No) { // check devices without benchmarks foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { if (cdev.Enabled) { bool Enabled = false; foreach (var algo in cdev.GetAlgorithmSettings()) { if (algo.BenchmarkSpeed > 0) { Enabled = true; break; } } cdev.Enabled = Enabled; } } } else { return(StartMiningReturnType.IgnoreMsg); } } textBoxBTCAddress.Enabled = false; textBoxWorkerName.Enabled = false; comboBoxLocation.Enabled = false; buttonBenchmark.Enabled = false; buttonStartMining.Enabled = false; buttonSettings.Enabled = false; devicesListViewEnableControl1.IsMining = true; buttonStopMining.Enabled = true; // Disable profitable notification on start IsNotProfitable = false; ConfigManager.GeneralConfig.BitcoinAddress = textBoxBTCAddress.Text.Trim(); ConfigManager.GeneralConfig.WorkerName = textBoxWorkerName.Text.Trim(); ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex; InitFlowPanelStart(); ClearRatesALL(); var btcAdress = DemoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim(); var isMining = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex], textBoxWorkerName.Text.Trim(), btcAdress); if (!DemoMode) { ConfigManager.GeneralConfigFileCommit(); } isSMAUpdated = true; // Always check profits on mining start SMAMinerCheck.Interval = 100; SMAMinerCheck.Start(); MinerStatsCheck.Start(); if (ConfigManager.GeneralConfig.RunScriptOnCUDA_GPU_Lost) { ComputeDevicesCheckTimer = new SystemTimer(); ComputeDevicesCheckTimer.Elapsed += ComputeDevicesCheckTimer_Tick; ComputeDevicesCheckTimer.Interval = 60000; ComputeDevicesCheckTimer.Start(); } return(isMining ? StartMiningReturnType.StartMining : StartMiningReturnType.ShowNoMining); }
private void UpdateGlobalRate() { double TotalRate = MinersManager.GetTotalRate(); if (ConfigManager.GeneralConfig.AutoScaleBTCValues && TotalRate < 0.1) { toolStripStatusLabelBTCDayText.Text = "mBTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); toolStripStatusLabelGlobalRateValue.Text = (TotalRate * 1000 * factorTimeUnit).ToString("F5", CultureInfo.InvariantCulture); } else { toolStripStatusLabelBTCDayText.Text = "BTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); toolStripStatusLabelGlobalRateValue.Text = (TotalRate * factorTimeUnit).ToString("F6", CultureInfo.InvariantCulture); } toolStripStatusLabelBTCDayValue.Text = ExchangeRateAPI.ConvertToActiveCurrency((TotalRate * factorTimeUnit * Globals.BitcoinUSDRate)).ToString("F2", CultureInfo.InvariantCulture); toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()) + " " + International.GetText("Form_Main_balance") + ":"; }
public void AddRateInfo(string groupName, string deviceStringInfo, APIData iAPIData, double paying, bool isApiGetException) { string ApiGetExceptionString = isApiGetException ? "**" : ""; string speedString = Helpers.FormatDualSpeedOutput(iAPIData.AlgorithmID, iAPIData.Speed, iAPIData.SecondarySpeed) + iAPIData.AlgorithmName + ApiGetExceptionString; string rateBTCString = FormatPayingOutput(paying); string rateCurrencyString = ExchangeRateAPI.ConvertToActiveCurrency(paying * Globals.BitcoinUSDRate * factorTimeUnit).ToString("F2", CultureInfo.InvariantCulture) + String.Format(" {0}/", ExchangeRateAPI.ActiveDisplayCurrency) + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); try { // flowLayoutPanelRatesIndex may be OOB, so catch ((GroupProfitControl)flowLayoutPanelRates.Controls[flowLayoutPanelRatesIndex++]) .UpdateProfitStats(groupName, deviceStringInfo, speedString, rateBTCString, rateCurrencyString); } catch { } UpdateGlobalRate(); }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; // Internals Init // TODO add loading step MinersSettingsManager.Init(); if (!Helpers.Is45NetOrHigher()) { MessageBox.Show(International.GetText("NET45_Not_Installed_msg"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } if (!Helpers.Is64BitOperatingSystem) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // 3rdparty miners check scope #1 { // check if setting set if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); } } // Query Avaliable ComputeDevices ComputeDeviceManager.Query.QueryDevices(LoadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.AfterDeviceQueryInitialization(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.SaveToGeneralConfig = true; LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); if (ComputeDeviceManager.Group.ContainsAMD_GPUs) { SMAMinerCheck.Interval = (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); // Init ws connection NiceHashStats.OnBalanceUpdate += BalanceCallback; NiceHashStats.OnSMAUpdate += SMACallback; NiceHashStats.OnVersionUpdate += VersionUpdateCallback; NiceHashStats.OnConnectionLost += ConnectionLostCallback; NiceHashStats.OnConnectionEstablished += ConnectionEstablishedCallback; NiceHashStats.OnVersionBurn += VersionBurnCallback; NiceHashStats.StartConnection(Links.NHM_Socket_Address); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); Helpers.SetDefaultEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.GeneralConfig.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (ConfigManager.GeneralConfig.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("Form_Main_loadtext_NVIDIAP0State")); Helpers.SetNvidiaP0State(); } LoadingScreen.FinishLoad(); bool runVCRed = !MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit; // standard miners check scope { // check if download needed if (!MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit) { Form_Loading downloadUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.StandardDlSetup)); SetChildFormCenter(downloadUnzipForm); downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit) { // all good ConfigManager.GeneralConfig.DownloadInit = true; ConfigManager.GeneralConfigFileCommit(); } } // 3rdparty miners check scope #2 { // check if download needed if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES) { if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit() && !ConfigManager.GeneralConfig.DownloadInit3rdParty) { Form_Loading download3rdPartyUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.ThirdPartyDlSetup)); SetChildFormCenter(download3rdPartyUnzipForm); download3rdPartyUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit3rdParty = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit3rdParty) { // all good ConfigManager.GeneralConfig.DownloadInit3rdParty = true; ConfigManager.GeneralConfigFileCommit(); } } } if (runVCRed) { Helpers.InstallVcRedist(); } if (ConfigManager.GeneralConfig.AutoStartMining) { // well this is started manually as we want it to start at runtime IsManuallyStarted = true; if (StartMining(true) != StartMiningReturnType.StartMining) { IsManuallyStarted = false; StopMining(); } } }
private void InitMainConfigGUIData() { if (ConfigManager.GeneralConfig.ServiceLocation >= 0 && ConfigManager.GeneralConfig.ServiceLocation < Globals.MiningLocation.Length) { comboBoxLocation.SelectedIndex = ConfigManager.GeneralConfig.ServiceLocation; } else { comboBoxLocation.SelectedIndex = 0; } textBoxBTCAddress.Text = ConfigManager.GeneralConfig.BitcoinAddress; textBoxWorkerName.Text = ConfigManager.GeneralConfig.WorkerName; ShowWarningNiceHashData = true; DemoMode = false; // init active display currency after config load ExchangeRateAPI.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency; // init factor for Time Unit switch (ConfigManager.GeneralConfig.TimeUnit) { case TimeUnitType.Hour: factorTimeUnit = 1.0 / 24.0; break; case TimeUnitType.Day: factorTimeUnit = 1; break; case TimeUnitType.Week: factorTimeUnit = 7; break; case TimeUnitType.Month: factorTimeUnit = 30; break; case TimeUnitType.Year: factorTimeUnit = 365; break; } toolStripStatusLabelBalanceDollarValue.Text = "(" + ExchangeRateAPI.ActiveDisplayCurrency + ")"; toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()) + " " + International.GetText("Form_Main_balance") + ":"; BalanceCallback(null, null); // update currency changes if (_isDeviceDetectionInitialized) { devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); } }
private void InitLocalization() { MessageBoxManager.Unregister(); MessageBoxManager.Yes = International.GetText("Global_Yes"); MessageBoxManager.No = International.GetText("Global_No"); MessageBoxManager.OK = International.GetText("Global_OK"); MessageBoxManager.Cancel = International.GetText("Global_Cancel"); MessageBoxManager.Retry = International.GetText("Global_Retry"); MessageBoxManager.Register(); labelServiceLocation.Text = International.GetText("Service_Location") + ":"; { int i = 0; foreach (string loc in Globals.MiningLocation) { comboBoxLocation.Items[i++] = International.GetText("LocationName_" + loc); } } labelBitcoinAddress.Text = International.GetText("BitcoinAddress") + ":"; labelWorkerName.Text = International.GetText("WorkerName") + ":"; linkLabelCheckStats.Text = International.GetText("Form_Main_check_stats"); linkLabelChooseBTCWallet.Text = International.GetText("Form_Main_choose_bitcoin_wallet"); toolStripStatusLabelGlobalRateText.Text = International.GetText("Form_Main_global_rate") + ":"; toolStripStatusLabelBTCDayText.Text = "BTC/" + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()); toolStripStatusLabelBalanceText.Text = (ExchangeRateAPI.ActiveDisplayCurrency + "/") + International.GetText(ConfigManager.GeneralConfig.TimeUnit.ToString()) + " " + International.GetText("Form_Main_balance") + ":"; devicesListViewEnableControl1.InitLocale(); buttonBenchmark.Text = International.GetText("Form_Main_benchmark"); buttonSettings.Text = International.GetText("Form_Main_settings"); buttonStartMining.Text = International.GetText("Form_Main_start"); buttonStopMining.Text = International.GetText("Form_Main_stop"); buttonHelp.Text = International.GetText("Form_Main_help"); label_NotProfitable.Text = International.GetText("Form_Main_MINING_NOT_PROFITABLE"); groupBox1.Text = International.GetText("Form_Main_Group_Device_Rates"); }