private static void StartPreventSleepTimer()
 {
     if (_preventSleepTimer?.IsActive ?? false)
     {
         return;
     }
     // sleep time setting is minimal 1 minute
     _preventSleepTimer = new AppTimer((s, e) => {
         PInvokeHelpers.PreventSleep();
     },
                                       20 * 1000);// leave this interval, it works
     _preventSleepTimer.Start();
 }
Esempio n. 2
0
        //public static bool StartDemoMining()
        //{
        //    StopMinerStatsCheckTimer();
        //    return false;
        //}

        private static bool StopMining(bool headless)
        {
            MiningManager.StopAllMiners();

            PInvokeHelpers.AllowMonitorPowerdownAndSleep();
            StopMinerStatsCheckTimer();
            StopComputeDevicesCheckTimer();
            StopPreventSleepTimer();
            StopInternetCheckTimer();
            DisplayNoInternetConnection(false); // hide warning
            DisplayMiningProfitable(true);      // hide warning
            return(true);
        }
        private static async Task MiningManagerMainLoop(CancellationToken stop)
        {
            try
            {
                var         checkWaitTime = TimeSpan.FromMilliseconds(50);
                Func <bool> isActive      = () => !stop.IsCancellationRequested;

                // sleep time setting is minimal 1 minute, 19-20s interval
                var preventSleepIntervalElapsedTimeChecker = new ElapsedTimeChecker(TimeSpan.FromSeconds(19), true);
                Logger.Info(Tag, "Starting MiningManagerMainLoop");
                while (isActive())
                {
                    if (isActive())
                    {
                        await TaskHelpers.TryDelay(checkWaitTime, stop);
                    }

                    // prevent sleep check
                    if (isActive() && preventSleepIntervalElapsedTimeChecker.CheckAndMarkElapsedTime())
                    {
                        var isMining = IsMiningEnabled;
                        if (isMining)
                        {
                            PInvokeHelpers.PreventSleep();
                        }
                        else
                        {
                            PInvokeHelpers.AllowMonitorPowerdownAndSleep();
                        }
                    }
                    // TODO should we check internet interval here???
                }
            }
            catch (TaskCanceledException e)
            {
                Logger.Info(Tag, $"MiningManagerMainLoop TaskCanceledException: {e.Message}");
            }
            catch (Exception e)
            {
                Logger.Error(Tag, $"TaskCanceledException Exception: {e.Message}");
            }
            finally
            {
                Logger.Info(Tag, "Exiting MiningManagerMainLoop run cleanup");
                // cleanup
                PInvokeHelpers.AllowMonitorPowerdownAndSleep();
            }
        }
Esempio n. 4
0
        static void Main(string[] argv)
        {
            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Application.ExecutablePath);

            if (path != null)
            {
                Environment.CurrentDirectory = path;
                pathSet = true;
            }

            // Add common folder to path for launched processes
            var pathVar = Environment.GetEnvironmentVariable("PATH");

            pathVar += ";" + Path.Combine(Environment.CurrentDirectory, "common");
            Environment.SetEnvironmentVariable("PATH", pathVar);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.CurrentCulture = 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
            var startProgram = true;

            if (ConfigManager.GeneralConfig.AllowMultipleInstances == false)
            {
                try
                {
                    var current = Process.GetCurrentProcess();
                    foreach (var 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)
                {
                    PInvokeHelpers.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);

                if (!pathSet)
                {
                    Helpers.ConsolePrint("NICEHASH", "Path not set to executable");
                }

                var tosChecked = ConfigManager.GeneralConfig.agreedWithTOS == Globals.CurrentTosVer;
                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.CurrentTosVer)
                    {
                        return;
                    }

                    if (ConfigManager.GeneralConfig.BitcoinAddress.Trim() == "")
                    {
                        var dialogSwitch = new EnterBTCDialogSwitch();
                        Application.Run(dialogSwitch);
                        if (dialogSwitch.IsLogin)
                        {
                            var loginForm = new LoginForm();
                            Application.Run(loginForm);
                            if (BitcoinAddress.ValidateBitcoinAddress(loginForm.Btc))
                            {
                                ConfigManager.GeneralConfig.BitcoinAddress = loginForm.Btc;
                                ConfigManager.GeneralConfigFileCommit();
                            }
                        }

                        Application.Run(new Form_Main());
                    }
                }
                else
                {
                    MessageBox.Show(International.GetText("Program_WMI_Error_Text"),
                                    International.GetText("Program_WMI_Error_Title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 5
0
        static void Main(string[] argv)
        {
            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Application.ExecutablePath);

            if (path != null)
            {
                Paths.SetRoot(path);
                Environment.CurrentDirectory = path;
                pathSet = true;
            }

            // Add common folder to path for launched processes
            var pathVar = Environment.GetEnvironmentVariable("PATH");

            pathVar += ";" + Path.Combine(Environment.CurrentDirectory, "common");
            Environment.SetEnvironmentVariable("PATH", pathVar);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            // set security protocols
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls
                                                    | SecurityProtocolType.Tls11
                                                    | SecurityProtocolType.Tls12
                                                    | SecurityProtocolType.Ssl3;

            // #1 first initialize config
            ConfigManager.InitializeConfig();

#warning "TODO Ensure that there is only a single instance running at time. Currenly the restart is broken if we close on multiple instances"
            // #2 check if multiple instances are allowed
            if (ConfigManager.GeneralConfig.AllowMultipleInstances == false)
            {
                try
                {
                    var current = Process.GetCurrentProcess();
                    foreach (var process in Process.GetProcessesByName(current.ProcessName))
                    {
                        if (process.Id != current.Id)
                        {
                            // already running instance, return from Main
                            return;
                        }
                    }
                }
                catch { }
            }


            // TODO set logging level
            Logger.ConfigureWithFile(ConfigManager.GeneralConfig.LogToFile, Level.Info, ConfigManager.GeneralConfig.LogMaxFileSize);

            if (ConfigManager.GeneralConfig.DebugConsole)
            {
                PInvokeHelpers.AllocConsole();
                Logger.ConfigureConsoleLogging(Level.Info);
            }

            // init active display currency after config load
            ExchangeRateApi.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency;

            Logger.Info("NICEHASH", $"Starting up {ApplicationStateManager.Title}");

            if (!pathSet)
            {
                Logger.Info("NICEHASH", "Path not set to executable");
            }

            // check TOS
            if (ConfigManager.GeneralConfig.agreedWithTOS != ApplicationStateManager.CurrentTosVer)
            {
                Logger.Info("NICEHASH", $"TOS differs! agreed: {ConfigManager.GeneralConfig.agreedWithTOS} != Current {ApplicationStateManager.CurrentTosVer}. Showing TOS Form.");

                Application.Run(new FormEula());
                // check TOS after
                if (ConfigManager.GeneralConfig.agreedWithTOS != ApplicationStateManager.CurrentTosVer)
                {
                    Logger.Info("NICEHASH", "TOS differs AFTER TOS confirmation FORM");
                    // TOS not confirmed return from Main
                    return;
                }
            }

            // if config created show language select
            if (string.IsNullOrEmpty(ConfigManager.GeneralConfig.Language))
            {
                if (Translations.GetAvailableLanguagesNames().Count > 1)
                {
                    Application.Run(new Form_ChooseLanguage());
                }
                else
                {
                    ConfigManager.GeneralConfig.Language = "en";
                    ConfigManager.GeneralConfigFileCommit();
                }
            }
            Translations.LanguageChanged += (s, e) => FormHelpers.TranslateAllOpenForms();
            Translations.SelectedLanguage = ConfigManager.GeneralConfig.Language;

            // if system requirements are not ensured it will fail the program
            var canRun = ApplicationStateManager.SystemRequirementsEnsured();
            if (!canRun)
            {
                return;
            }

            // 3rdparty miners TOS check if setting set
            if (ConfigManager.GeneralConfig.Use3rdPartyMinersTOS != ApplicationStateManager.CurrentTosVer)
            {
                using (var secondTOS = new Form_3rdParty_TOS())
                {
                    Application.Run(secondTOS);
                    if (!secondTOS.Accepted)
                    {
                        return;
                    }
                }
                ConfigManager.GeneralConfigFileCommit();
            }

#warning "Login form feature is missing (only discontinued old platform supports it)"
#if false
            // if no BTC address show login/register form
            if (ConfigManager.GeneralConfig.BitcoinAddress.Trim() == "")
            {
                Application.Run(new EnterBTCDialogSwitch());
            }
#endif

            Application.Run(new Form_Main());
        }
Esempio n. 6
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (path != null)
            {
                Paths.SetRoot(path);
                Environment.CurrentDirectory = path;
                pathSet = true;
            }

            // Add common folder to path for launched processes
            const string pathKey = "PATH";
            var          pathVar = Environment.GetEnvironmentVariable(pathKey);

            pathVar += $";{Path.Combine(Environment.CurrentDirectory, "common")}";
            Environment.SetEnvironmentVariable(pathKey, pathVar);

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Set security protocols
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls |
                                                    SecurityProtocolType.Tls11 |
                                                    SecurityProtocolType.Tls12 |
                                                    SecurityProtocolType.Ssl3;

            // Initialize config
            ConfigManager.InitializeConfig();

            // Check multiple instances
            if (!ConfigManager.GeneralConfig.AllowMultipleInstances)
            {
                try
                {
                    var current = Process.GetCurrentProcess();
                    if (Process.GetProcessesByName(current.ProcessName).Any(p => p.Id != current.Id))
                    {
                        // Shutdown to exit
                        Shutdown();
                    }
                }
                catch
                { }
            }

            // Init logger
            Logger.ConfigureWithFile(ConfigManager.GeneralConfig.LogToFile, Level.Info, ConfigManager.GeneralConfig.LogMaxFileSize);

            if (ConfigManager.GeneralConfig.DebugConsole)
            {
                PInvokeHelpers.AllocConsole();
                Logger.ConfigureConsoleLogging(Level.Info);
            }

            if (!pathSet)
            {
                Logger.Warn(Tag, "Path not set to executable");
            }

            // Set to explicit shutdown or else these intro windows will cause shutdown
            ShutdownMode = ShutdownMode.OnExplicitShutdown;

            // Init ExchangeRateApi and TimeUnit
            ExchangeRateApi.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency;
            TimeFactor.UnitType = ConfigManager.GeneralConfig.TimeUnit;

            Logger.Info(Tag, $"Starting up {ApplicationStateManager.Title}");

            if (ConfigManager.GeneralConfig.agreedWithTOS != ApplicationStateManager.CurrentTosVer)
            {
                Logger.Info(Tag, $"TOS differs! agreed: {ConfigManager.GeneralConfig.agreedWithTOS} != Current {ApplicationStateManager.CurrentTosVer}");

                var eula = new EulaWindow
                {
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };

                var accepted = eula.ShowDialog();

                if (accepted ?? false)
                {
                    ConfigManager.GeneralConfig.agreedWithTOS = ApplicationStateManager.CurrentTosVer;
                }
                else
                {
                    Logger.Error(Tag, "TOS differs AFTER TOS confirmation window");
                    Shutdown();
                }
            }

            // Chose lang
            if (string.IsNullOrEmpty(ConfigManager.GeneralConfig.Language))
            {
                var langToSet = "en";
                if (Translations.GetAvailableLanguagesNames().Count > 1)
                {
                    var lang = new ChooseLanguageWindow
                    {
                        LangNames             = Translations.GetAvailableLanguagesNames(),
                        WindowStartupLocation = WindowStartupLocation.CenterScreen
                    };

                    lang.ShowDialog();

                    langToSet = Translations.GetLanguageCodeFromIndex(lang.SelectedLangIndex);
                }

                ConfigManager.GeneralConfig.Language = langToSet;
                ConfigManager.GeneralConfigFileCommit();
            }

            Translations.SelectedLanguage = ConfigManager.GeneralConfig.Language;

            // Check sys requirements
            var canRun = ApplicationStateManager.SystemRequirementsEnsured();

            if (!canRun)
            {
                Shutdown();
            }

            // Check 3rd party miners
            if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET)
            {
                var thirdPty = new _3rdPartyTosWindow
                {
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                };

                var result = thirdPty.ShowDialog();

                // Note result is a Nullable<bool>, hence the verbose if-else
                if (result == true)
                {
                    ConfigManager.GeneralConfig.Use3rdPartyMiners = Use3rdPartyMiners.YES;
                }
                else if (result == false)
                {
                    ConfigManager.GeneralConfig.Use3rdPartyMiners = Use3rdPartyMiners.NO;
                }

                ConfigManager.GeneralConfigFileCommit();
            }

            var main = new MainWindow();

            main.Show();

            // Set shutdown mode back to default
            ShutdownMode = ShutdownMode.OnLastWindowClose;
        }
Esempio n. 7
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
#if __DESIGN_DEVELOP
            var designWindow = new __DESIGN_DEVELOP();
            designWindow.ShowDialog();
            return;
#endif
            RenderOptions.ProcessRenderMode         = RenderMode.SoftwareOnly;
            ApplicationStateManager.App             = this;
            ApplicationStateManager.ApplicationExit = () =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    this.Shutdown();
                });
            };
            var isLauncher  = Environment.GetCommandLineArgs().Contains("-lc");
            var launcherPID = ParseLauncherPID();
            Launcher.SetIsUpdated(Environment.GetCommandLineArgs().Contains("-updated"));
            Launcher.SetIsUpdatedFailed(Environment.GetCommandLineArgs().Contains("-updateFailed"));
            Launcher.SetIsLauncher(isLauncher);
            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            if (path != null)
            {
                if (isLauncher)
                {
                    var oneUpPath = new Uri(Path.Combine(path, @"..\")).LocalPath;
                    Paths.SetRoot(oneUpPath);
                    Paths.SetAppRoot(path);
                    // TODO this might be problematic
                    Environment.CurrentDirectory = oneUpPath;
                }
                else
                {
                    Paths.SetRoot(path);
                    Paths.SetAppRoot(path);
                    Environment.CurrentDirectory = path;
                }
                pathSet = true;
            }

            // Add common folder to path for launched processes
            const string pathKey = "PATH";
            var          pathVar = Environment.GetEnvironmentVariable(pathKey);
            pathVar += $";{Path.Combine(Paths.AppRoot, "common")}";
            Environment.SetEnvironmentVariable(pathKey, pathVar);

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Set security protocols
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls |
                                                    SecurityProtocolType.Tls11 |
                                                    SecurityProtocolType.Tls12 |
                                                    SecurityProtocolType.Ssl3;

            // Initialize config
            ConfigManager.InitializeConfig();

            ThemeSetterManager.SetTheme(GUISettings.Instance.DisplayTheme);

            // Check multiple instances
            if (!MiscSettings.Instance.AllowMultipleInstances)
            {
                try
                {
                    var current      = Process.GetCurrentProcess();
                    var processesIds = Process.GetProcessesByName(current.ProcessName).Select(p => p.Id);
                    if (processesIds.Any(pid => pid != current.Id && pid != launcherPID))
                    {
                        var singleInstanceNotice = new SingleInstanceNotice {
                        };
                        singleInstanceNotice.ShowDialog();
                        // Shutdown to exit
                        Shutdown();
                        return;
                    }
                }
                catch
                { }
            }

            // Init logger
            Logger.ConfigureWithFile(LoggingDebugConsoleSettings.Instance.LogToFile, Level.Info, LoggingDebugConsoleSettings.Instance.LogMaxFileSize);

            if (LoggingDebugConsoleSettings.Instance.DebugConsole)
            {
                PInvokeHelpers.AllocConsole();
                Logger.ConfigureConsoleLogging(Level.Info);
            }

            if (!pathSet)
            {
                Logger.Warn(Tag, "Path not set to executable");
            }

            // Set to explicit shutdown or else these intro windows will cause shutdown
            ShutdownMode = ShutdownMode.OnExplicitShutdown;

            Logger.Info(Tag, $"Starting up {ApplicationStateManager.Title}");
            if (ToSSetings.Instance.AgreedWithTOS != ApplicationStateManager.CurrentTosVer)
            {
                Logger.Info(Tag, $"TOS differs! agreed: {ToSSetings.Instance.AgreedWithTOS} != Current {ApplicationStateManager.CurrentTosVer}");

                var eula     = new EulaWindowFirstLong {
                };
                var accepted = eula.ShowDialog();
                if (accepted.HasValue && eula.AcceptedTos)
                {
                    ToSSetings.Instance.AgreedWithTOS = ApplicationStateManager.CurrentTosVer;
                }
                else
                {
                    Logger.Error(Tag, "TOS differs AFTER TOS confirmation window");
                    Shutdown();
                    return;
                }
            }

            // Check 3rd party miners TOS
            if (ToSSetings.Instance.Use3rdPartyMinersTOS != ApplicationStateManager.CurrentTosVer)
            {
                var thirdPty = new EulaWindowSecondShort {
                };
                thirdPty.ShowDialog();
                if (!thirdPty.Accepted)
                {
                    Logger.Error(Tag, "3rd party TOS not accepted");
                    Shutdown();
                    return;
                }
                ToSSetings.Instance.Use3rdPartyMinersTOS = ApplicationStateManager.CurrentTosVer;
                ConfigManager.GeneralConfigFileCommit();
            }

            // Chose lang
            if (string.IsNullOrEmpty(TranslationsSettings.Instance.Language) && AppRuntimeSettings.ShowLanguage)
            {
                if (Translations.GetAvailableLanguagesNames().Count > 1)
                {
                    var lang = new ChooseLanguageWindow {
                    };
                    lang.ShowDialog();
                }
                // check if user didn't choose anything
                if (string.IsNullOrEmpty(TranslationsSettings.Instance.Language))
                {
                    TranslationsSettings.Instance.Language = "en";
                }
                ConfigManager.GeneralConfigFileCommit();
            }
            else if (string.IsNullOrEmpty(TranslationsSettings.Instance.Language) && !AppRuntimeSettings.ShowLanguage)
            {
                // while we have locale disabled set english
                TranslationsSettings.Instance.Language = "en";
                ConfigManager.GeneralConfigFileCommit();
            }

            Translations.SelectedLanguage = TranslationsSettings.Instance.Language;

            // Check sys requirements
            var canRun = ApplicationStateManager.SystemRequirementsEnsured();
            if (!canRun)
            {
                Shutdown();
                return;
            }

#if ENABLE_LOGIN
            FilterOSSpecific.GetWindowsVersion();
            // show login if no BTC
            if (!CredentialsSettings.Instance.IsBitcoinAddressValid && AppRuntimeSettings.ShowLoginWindow && SystemVersion.BuildNumber >= 17110)
            {
                var login = new LoginWindow {
                };
                var nek   = login.ShowDialog();
            }
#endif
            if (!CredentialsSettings.Instance.IsBitcoinAddressValid)
            {
                var btcNotice = new DemoBTCNotice {
                };
                btcNotice.ShowDialog();
            }

            var main = new MainWindow();
            main.Show();

            //// Set shutdown mode back to default
            //ShutdownMode = ShutdownMode.OnLastWindowClose;
        }
Esempio n. 8
0
        static void Main(string[] argv)
        {
            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Application.ExecutablePath);

            if (path != null)
            {
                Environment.CurrentDirectory = path;
                pathSet = true;
            }

            // Add common folder to path for launched processes
            var pathVar = Environment.GetEnvironmentVariable("PATH");

            pathVar += ";" + Path.Combine(Environment.CurrentDirectory, "common");
            Environment.SetEnvironmentVariable("PATH", pathVar);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.CurrentCulture = 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
            if (ConfigManager.GeneralConfig.AllowMultipleInstances == false)
            {
                try
                {
                    var current = Process.GetCurrentProcess();
                    foreach (var process in Process.GetProcessesByName(current.ProcessName))
                    {
                        if (process.Id != current.Id)
                        {
                            // already running instance, return from Main
                            return;
                        }
                    }
                }
                catch { }
            }

            // start program
            if (ConfigManager.GeneralConfig.LogToFile)
            {
                Logger.ConfigureWithFile();
            }

            if (ConfigManager.GeneralConfig.DebugConsole)
            {
                PInvokeHelpers.AllocConsole();
            }

            // init active display currency after config load
            ExchangeRateApi.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency;

            Helpers.ConsolePrint("NICEHASH", "Starting up NiceHashMiner v" + Application.ProductVersion);

            if (!pathSet)
            {
                Helpers.ConsolePrint("NICEHASH", "Path not set to executable");
            }

            // check TOS
            if (ConfigManager.GeneralConfig.agreedWithTOS != Globals.CurrentTosVer)
            {
                Helpers.ConsolePrint("NICEHASH", $"TOS differs! agreed: ${ConfigManager.GeneralConfig.agreedWithTOS} != Current ${Globals.CurrentTosVer}. Showing TOS Form.");
                Application.Run(new FormEula());
                // check TOS after
                if (ConfigManager.GeneralConfig.agreedWithTOS != Globals.CurrentTosVer)
                {
                    Helpers.ConsolePrint("NICEHASH", $"TOS differs AFTER TOS confirmation FORM");
                    // TOS not confirmed return from Main
                    return;
                }
            }
            // if config created show language select
            if (string.IsNullOrEmpty(ConfigManager.GeneralConfig.Language))
            {
                if (Translations.GetAvailableLanguagesNames().Count > 1)
                {
                    Application.Run(new Form_ChooseLanguage());
                }
                else
                {
                    ConfigManager.GeneralConfig.Language = "en";
                    ConfigManager.GeneralConfigFileCommit();
                }
            }
            Translations.SetLanguage(ConfigManager.GeneralConfig.Language);

            // check WMI
            if (Helpers.IsWmiEnabled())
            {
                // if no BTC address show login/register form
                if (ConfigManager.GeneralConfig.BitcoinAddress.Trim() == "")
                {
                    Application.Run(new EnterBTCDialogSwitch());
                }
                // finally run
                Application.Run(new Form_Main());
            }
            else
            {
                MessageBox.Show(Translations.Tr("NiceHash Miner Legacy cannot run needed components. It seems that your system has Windows Management Instrumentation service Disabled. In order for NiceHash Miner Legacy to work properly Windows Management Instrumentation service needs to be Enabled. This service is needed to detect RAM usage and Avaliable Video controler information. Enable Windows Management Instrumentation service manually and start NiceHash Miner Legacy."),
                                Translations.Tr("Windows Management Instrumentation Error"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 9
0
        static void Main(string[] argv)
        {
            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Application.ExecutablePath);

            if (path != null)
            {
                Environment.CurrentDirectory = path;
                pathSet = true;
            }

            // Add common folder to path for launched processes
            var pathVar = Environment.GetEnvironmentVariable("PATH");

            pathVar += ";" + Path.Combine(Environment.CurrentDirectory, "common");
            Environment.SetEnvironmentVariable("PATH", pathVar);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.CurrentCulture = 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
            var startProgram = true;

            if (ConfigManager.GeneralConfig.AllowMultipleInstances == false)
            {
                try
                {
                    var current = Process.GetCurrentProcess();
                    foreach (var 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)
                {
                    PInvokeHelpers.AllocConsole();
                }
                //**

                /*
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 4)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (File.Exists("internals\\MinerOptionPackage_glg.json"))
                 *      File.Delete("internals\\MinerOptionPackage_glg.json");
                 *
                 *  if (File.Exists("internals\\MinerOptionPackage_ClaymoreDual.json"))
                 *      File.Delete("internals\\MinerOptionPackage_ClaymoreDual.json");
                 *
                 *  if (File.Exists("bin\\ccminer_klaust\\ccminer.exe"))
                 *      File.Delete("bin\\ccminer_klaust\\ccminer.exe");
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 4;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 4.1)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (File.Exists("internals\\MinerOptionPackage_ClaymoreDual.json"))
                 *      File.Delete("internals\\MinerOptionPackage_ClaymoreDual.json");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 4.1;
                 * }
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 5)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 5;
                 * }
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 6)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 6;
                 * }
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 7)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 7;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 8)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 8;
                 * }
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 8.2)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 8.2;
                 * }
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 9;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9.1)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe"))
                 *      File.Delete("bin_3rdparty\\t-rex\\t-rex.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 9.1;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9.2)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe"))
                 *      File.Delete("bin_3rdparty\\t-rex\\t-rex.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 9.2;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 9.3)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe"))
                 *      File.Delete("bin_3rdparty\\t-rex\\t-rex.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 9.3;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 10)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe"))
                 *      File.Delete("bin_3rdparty\\t-rex\\t-rex.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 10;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 11)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  if (File.Exists("bin\\xmrig\\xmrig.exe"))
                 *      File.Delete("bin\\xmrig\\xmrig.exe");
                 *
                 *  if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe"))
                 *      File.Delete("bin_3rdparty\\t-rex\\t-rex.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 11;
                 * }
                 *
                 * if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 11.1)
                 * {
                 *  Helpers.ConsolePrint("NICEHASH", "Old version");
                 *  if (Directory.Exists("internals"))
                 *      Directory.Delete("internals", true);
                 *
                 *  if (File.Exists("bin_3rdparty\\t-rex\\t-rex.exe"))
                 *      File.Delete("bin_3rdparty\\t-rex\\t-rex.exe");
                 *
                 *  ConfigManager.GeneralConfig.ForkFixVersion = 11.1;
                 * }
                 */
                if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 11.2)
                {
                    Helpers.ConsolePrint("NICEHASH", "Old version");
                    if (Directory.Exists("internals"))
                    {
                        Directory.Delete("internals", true);
                    }
                    ConfigManager.GeneralConfig.ForkFixVersion = 11.2;
                }

                if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 12)
                {
                    Helpers.ConsolePrint("NICEHASH", "Old version");
                    if (Directory.Exists("internals"))
                    {
                        Directory.Delete("internals", true);
                    }
                    ConfigManager.GeneralConfig.ForkFixVersion = 12;
                }
                if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 12.1)
                {
                    Helpers.ConsolePrint("NICEHASH", "Old version");
                    if (Directory.Exists("internals"))
                    {
                        Directory.Delete("internals", true);
                    }
                    ConfigManager.GeneralConfig.ForkFixVersion = 12.1;
                }
                if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 13)
                {
                    Helpers.ConsolePrint("NICEHASH", "Old version");
                    if (Directory.Exists("internals"))
                    {
                        Directory.Delete("internals", true);
                    }
                    ConfigManager.GeneralConfig.ForkFixVersion = 13;
                }
                if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 13.1)
                {
                    Helpers.ConsolePrint("NICEHASH", "Old version");
                    if (Directory.Exists("internals"))
                    {
                        Directory.Delete("internals", true);
                    }
                    ConfigManager.GeneralConfig.ForkFixVersion = 13.1;
                }
                if (Configs.ConfigManager.GeneralConfig.ForkFixVersion < 14)
                {
                    Helpers.ConsolePrint("NICEHASH", "Old version");
                    if (Directory.Exists("internals"))
                    {
                        Directory.Delete("internals", true);
                    }
                    ConfigManager.GeneralConfig.ForkFixVersion = 14.0;
                }
                //**
                Thread.Sleep(500);
                // 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);

                if (!pathSet)
                {
                    Helpers.ConsolePrint("NICEHASH", "Path not set to executable");
                }

                var tosChecked = ConfigManager.GeneralConfig.agreedWithTOS == Globals.CurrentTosVer;
                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.CurrentTosVer)
                    {
                        Application.Run(new Form_Main());
                    }
                }
                else
                {
                    MessageBox.Show(International.GetText("Program_WMI_Error_Text"),
                                    International.GetText("Program_WMI_Error_Title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 10
0
        static void Main(string[] argv)
        {
            // log unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionLogger);
            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionLogger);

            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Application.ExecutablePath);

            if (path != null)
            {
                Environment.CurrentDirectory = path;
                pathSet = true;
            }

            // Add common folder to path for launched processes
            var pathVar = Environment.GetEnvironmentVariable("PATH");

            pathVar += ";" + Path.Combine(Environment.CurrentDirectory, "common");
            Environment.SetEnvironmentVariable("PATH", pathVar);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.CurrentCulture = 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
            var startProgram = true;

            if (ConfigManager.GeneralConfig.AllowMultipleInstances == false)
            {
                try
                {
                    var current = Process.GetCurrentProcess();
                    foreach (var 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)
                {
                    PInvokeHelpers.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);

                if (!pathSet)
                {
                    Helpers.ConsolePrint("NICEHASH", "Path not set to executable");
                }

                /* Preset language to RU and icence aggreement */
                ConfigManager.InitializeConfig();
                ConfigManager.GeneralConfig.agreedWithTOS = Globals.CurrentTosVer;
                ConfigManager.GeneralConfig.SetDefaults();
                ConfigManager.GeneralConfigFileCommit();
                ConfigManager.HideTrayIcon         = commandLineArgs.hideTrayIcon;
                ConfigManager.HideEmail            = commandLineArgs.hideEmail;
                ConfigManager.TestDriverUpdateForm = commandLineArgs.testDriverUpdateForm;


                var tosChecked = ConfigManager.GeneralConfig.agreedWithTOS == Globals.CurrentTosVer;
                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;
                }

                if (ConfigManager.GeneralConfig.Account == null || ConfigManager.GeneralConfig.WorkerName == "")
                {
                    Application.Run(new Form_Authorization());
                }
                else
                {
                    WebAPI.UpdateMachineInfo(ConfigManager.GeneralConfig.WorkerName);
                }

                // check WMI
                if (ConfigManager.GeneralConfig.Account != null)
                {
                    if (Helpers.IsWmiEnabled())
                    {
                        if (ConfigManager.GeneralConfig.agreedWithTOS == Globals.CurrentTosVer)
                        {
                            while (true)
                            {
                                Application.Run(new Form_Main());
                                if (ConfigManager.GeneralConfig.Account == null)
                                {
                                    Application.Run(new Form_Authorization());
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(International.GetText("Program_WMI_Error_Text"),
                                        International.GetText("Program_WMI_Error_Title"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Вы должны сначала авторизоваться в системе!", "Ошибка",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 11
0
        static void Main(string[] argv)
        {
            BUILD_TAG.ASSERT_COMPATIBLE_BUILDS();
            // Set working directory to exe
            var pathSet = false;
            var path    = Path.GetDirectoryName(Application.ExecutablePath);

            if (path != null)
            {
                Paths.SetRoot(path);
                Environment.CurrentDirectory = path;
                pathSet = true;
            }

            // Add common folder to path for launched processes
            var pathVar = Environment.GetEnvironmentVariable("PATH");

            pathVar += ";" + Path.Combine(Environment.CurrentDirectory, "common");
            Environment.SetEnvironmentVariable("PATH", pathVar);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            // set security protocols
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls
                                                    | SecurityProtocolType.Tls11
                                                    | SecurityProtocolType.Tls12
                                                    | SecurityProtocolType.Ssl3;

            // #1 first initialize config
            ConfigManager.InitializeConfig();

//            // PRODUCTION NEW
//#if (TESTNET || TESTNETDEV || PRODUCTION_NEW)
//            // TODO disable this as it breaks restart functionality
//            //// on new production we allow only one instance
//            //try
//            //{
//            //    var current = Process.GetCurrentProcess();
//            //    foreach (var process in Process.GetProcessesByName(current.ProcessName))
//            //    {
//            //        if (process.Id != current.Id)
//            //        {
//            //            // already running instance, return from Main
//            //            MessageBox.Show(Tr("{0} can run only one instance at a time.", NHMProductInfo.Name),
//            //            Tr("{0} Already Running", NHMProductInfo.Name),
//            //            MessageBoxButtons.OK, MessageBoxIcon.Error);
//            //            return;
//            //        }
//            //    }
//            //}
//            //catch { }
//#else
//            // PRODUCTION OLD
            // #2 check if multiple instances are allowed
            if (ConfigManager.GeneralConfig.AllowMultipleInstances == false)
            {
                try
                {
                    var current = Process.GetCurrentProcess();
                    foreach (var process in Process.GetProcessesByName(current.ProcessName))
                    {
                        if (process.Id != current.Id)
                        {
                            // already running instance, return from Main
                            return;
                        }
                    }
                }
                catch { }
            }
//#endif


            // TODO set logging level
            Logger.ConfigureWithFile(ConfigManager.GeneralConfig.LogToFile, Level.Info, ConfigManager.GeneralConfig.LogMaxFileSize);

            if (ConfigManager.GeneralConfig.DebugConsole)
            {
                PInvokeHelpers.AllocConsole();
            }

            // init active display currency after config load
            ExchangeRateApi.ActiveDisplayCurrency = ConfigManager.GeneralConfig.DisplayCurrency;

            Logger.Info("NICEHASH", $"Starting up {ApplicationStateManager.Title}");

            if (!pathSet)
            {
                Logger.Info("NICEHASH", "Path not set to executable");
            }

            // check TOS
            if (ConfigManager.GeneralConfig.agreedWithTOS != ApplicationStateManager.CurrentTosVer)
            {
                Logger.Info("NICEHASH", $"TOS differs! agreed: {ConfigManager.GeneralConfig.agreedWithTOS} != Current {ApplicationStateManager.CurrentTosVer}. Showing TOS Form.");

                Application.Run(new FormEula());
                // check TOS after
                if (ConfigManager.GeneralConfig.agreedWithTOS != ApplicationStateManager.CurrentTosVer)
                {
                    Logger.Info("NICEHASH", "TOS differs AFTER TOS confirmation FORM");
                    // TOS not confirmed return from Main
                    return;
                }
            }

            // if config created show language select
            if (string.IsNullOrEmpty(ConfigManager.GeneralConfig.Language))
            {
                if (Translations.GetAvailableLanguagesNames().Count > 1)
                {
                    Application.Run(new Form_ChooseLanguage());
                }
                else
                {
                    ConfigManager.GeneralConfig.Language = "en";
                    ConfigManager.GeneralConfigFileCommit();
                }
            }
            Translations.SetLanguage(ConfigManager.GeneralConfig.Language);

            // if system requirements are not ensured it will fail the program
            var canRun = ApplicationStateManager.SystemRequirementsEnsured();

            if (!canRun)
            {
                return;
            }

            // 3rdparty miners TOS check if setting set
            if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET)
            {
                Application.Run(new Form_3rdParty_TOS());
                ConfigManager.GeneralConfigFileCommit();
            }

            // PRODUCTION
#if !(TESTNET || TESTNETDEV || PRODUCTION_NEW)
            // if no BTC address show login/register form
            if (ConfigManager.GeneralConfig.BitcoinAddress.Trim() == "")
            {
                Application.Run(new EnterBTCDialogSwitch());
            }
#endif
            Application.Run(new Form_Main());
        }