public Form1(bool ss) { InitializeComponent(); if (ss) { Form4 f4 = new Form4(); f4.ShowDialog(); } if (Config.ConfigData.DebugConsole) { Helpers.AllocConsole(); } Helpers.ConsolePrint("Starting up"); R = new Random((int)DateTime.Now.Ticks); Text += " v" + Application.ProductVersion; if (Config.ConfigData.Location >= 0 && Config.ConfigData.Location < 3) { comboBox1.SelectedIndex = Config.ConfigData.Location; } else { comboBox1.SelectedIndex = 0; } textBox1.Text = Config.ConfigData.BitcoinAddress; textBox2.Text = Config.ConfigData.WorkerName; }
static void Main(string[] argv) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; 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.Instance.GeneralConfig.InitializeConfig(); ConfigManager.Instance.LegacyConfigMigration(); if (ConfigManager.Instance.GeneralConfig.LogToFile) { Logger.ConfigureWithFile(); } if (ConfigManager.Instance.GeneralConfig.DebugConsole) { Helpers.AllocConsole(); } // #2 then parse args var commandLineArgs = new CommandLineParser(argv); Helpers.ConsolePrint("NICEHASH", "Starting up NiceHashMiner v" + Application.ProductVersion); if (!ConfigManager.Instance.GeneralConfig.IsFileExist() && !commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "No config file found. Running NiceHash Miner for the first time. Choosing a default language."); Application.Run(new Form_ChooseLanguage()); } // Init languages International.Initialize(ConfigManager.Instance.GeneralConfig.Language); if (commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "Language is overwritten by command line parameter (-lang)."); International.Initialize(commandLineArgs.LangValue); ConfigManager.Instance.GeneralConfig.Language = commandLineArgs.LangValue; } Application.Run(new Form_Main()); }
static void Main(string[] argv) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool ConfigExist = Config.ConfigFileExist(); Config.InitializeConfig(); if (Config.ConfigData.LogToFile) { Logger.ConfigureWithFile(); } if (Config.ConfigData.DebugConsole) { Helpers.AllocConsole(); } Helpers.ConsolePrint("NICEHASH", "Starting up NiceHashMiner v" + Application.ProductVersion); string tmp; if (!ConfigExist && !ParseCommandLine(argv, "-lang", out tmp)) { Helpers.ConsolePrint("NICEHASH", "No config file found. Running NiceHash Miner for the first time. Choosing a default language."); Application.Run(new Form_ChooseLanguage()); } // Init languages International.Initialize(Config.ConfigData.Language); if (argv.Length > 0) { if (ParseCommandLine(argv, "-lang", out tmp)) { int lang; if (Int32.TryParse(tmp, out lang)) { Helpers.ConsolePrint("NICEHASH", "Language is overwritten by command line parameter (-lang)."); International.Initialize(lang); Config.ConfigData.Language = lang; } } if (ParseCommandLine(argv, "-config", out tmp)) { Application.Run(new Form1(true)); } } Application.Run(new Form1(false)); }
public Form1(bool ss) { InitializeComponent(); if (ss) { Form4 f4 = new Form4(); f4.ShowDialog(); } if (Config.ConfigData.LogLevel > 0) { Logger.ConfigureWithFile(); } if (Config.ConfigData.DebugConsole) { Helpers.AllocConsole(); } Helpers.ConsolePrint("NICEHASH", "Starting up"); // Log the computer's amount of Total RAM and Page File Size ManagementObjectCollection moc = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem").Get(); foreach (ManagementObject mo in moc) { long TotalRam = long.Parse(mo["TotalVisibleMemorySize"].ToString()) / 1024; long PageFileSize = (long.Parse(mo["TotalVirtualMemorySize"].ToString()) / 1024) - TotalRam; Helpers.ConsolePrint("NICEHASH", "Total RAM: " + TotalRam + "MB"); Helpers.ConsolePrint("NICEHASH", "Page File Size: " + PageFileSize + "MB"); } R = new Random((int)DateTime.Now.Ticks); Text += " v" + Application.ProductVersion; if (Config.ConfigData.Location >= 0 && Config.ConfigData.Location < MiningLocation.Length) { comboBox1.SelectedIndex = Config.ConfigData.Location; } else { comboBox1.SelectedIndex = 0; } textBox1.Text = Config.ConfigData.BitcoinAddress; textBox2.Text = Config.ConfigData.WorkerName; ShowWarningNiceHashData = true; }
static void Main(string[] argv) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var commandLineArgs = new CommandLineParser(argv); bool ConfigExist = Config.ConfigFileExist(); Config.InitializeConfig(); if (Config.ConfigData.LogToFile) { Logger.ConfigureWithFile(); } if (Config.ConfigData.DebugConsole) { Helpers.AllocConsole(); } Helpers.ConsolePrint("NICEHASH", "Starting up NiceHashMiner v" + Application.ProductVersion); if (!ConfigExist && !commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "No config file found. Running NiceHash Miner for the first time. Choosing a default language."); Application.Run(new Form_ChooseLanguage()); } // Init languages International.Initialize(Config.ConfigData.Language); if (commandLineArgs.IsLang) { Helpers.ConsolePrint("NICEHASH", "Language is overwritten by command line parameter (-lang)."); International.Initialize(commandLineArgs.LangValue); Config.ConfigData.Language = commandLineArgs.LangValue; } Application.Run(new Form_Main(commandLineArgs.IsConfig)); }
static void Main(string[] argv) { 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 NiceHashMiner 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 NiceHash Miner Legacy 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; } // 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); } } }