Exemple #1
0
        private void FormSettings_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (IsChange && !IsChangeSaved)
            {
                DialogResult result = MessageBox.Show(International.GetText("Form_Settings_buttonCloseNoSaveMsg"),
                                                      International.GetText("Form_Settings_buttonCloseNoSaveTitle"),
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result == DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            // check restart parameters change
            IsRestartNeeded = ConfigManager.IsRestartNeeded();

            if (IsChangeSaved)
            {
                ConfigManager.GeneralConfigFileCommit();
                ConfigManager.CommitBenchmarks();
                International.Initialize(ConfigManager.GeneralConfig.Language);
            }
            else
            {
                ConfigManager.RestoreBackup();
            }
        }
Exemple #2
0
        public MainWindow()
        {
            IsClose     = false;
            _notifyIcon = new NotifyIcon();
            _notifyIcon.MouseDoubleClick += NotifyIconOnMouseDoubleClick;
            var menuItem1 = new MenuItem
            {
                Index = 0,
                Text  = "Exit"
            };

            menuItem1.Click += MenuItem1OnClick;

            _notifyIcon.ContextMenu = new ContextMenu();
            _notifyIcon.ContextMenu.MenuItems.Add(menuItem1);
            Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/bCash;component/Resources/icon_.ico")).Stream;

            _notifyIcon.Icon    = new System.Drawing.Icon(iconStream);
            _notifyIcon.Visible = true;
            if (!ConfigManager.GeneralConfigIsFileExist())
            {
                Helpers.ConsolePrint("NICEHASH", "No config file found. Running NiceHash Miner for the first time. Choosing a default language.");
                var showDlg = new ChoosingLanguageWindow();
                showDlg.ShowDialog();
            }

            // Init languages
            International.Initialize(ConfigManager.GeneralConfig.Language);
            InitializeComponent();
            ((MainViewModel)DataContext).SetDialogCoordinator(DialogCoordinator.Instance);
        }
Exemple #3
0
        private void buttonDefaults_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(International.GetText("Form_Settings_buttonDefaultsMsg"),
                                                  International.GetText("Form_Settings_buttonDefaultsTitle"),
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                IsChange      = true;
                IsChangeSaved = true;
                ConfigManager.GeneralConfig.SetDefaults();

                International.Initialize(ConfigManager.GeneralConfig.Language);
                InitializeGeneralTabFieldValuesReferences();
                InitializeGeneralTabTranslations();
            }
        }
Exemple #4
0
        private void FormSettings_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (IsChange && !IsChangeSaved)
            {
                DialogResult result = MessageBox.Show(International.GetText("Form_Settings_buttonCloseNoSaveMsg"),
                                                      International.GetText("Form_Settings_buttonCloseNoSaveTitle"),
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result == DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            // check restart parameters change
            IsRestartNeeded = ConfigManager.Instance.GeneralConfig.DebugConsole != _generalConfigBackup.DebugConsole ||
                              ConfigManager.Instance.GeneralConfig.NVIDIAP0State != _generalConfigBackup.NVIDIAP0State ||
                              ConfigManager.Instance.GeneralConfig.LogToFile != _generalConfigBackup.LogToFile ||
                              ConfigManager.Instance.GeneralConfig.SwitchMinSecondsFixed != _generalConfigBackup.SwitchMinSecondsFixed ||
                              ConfigManager.Instance.GeneralConfig.SwitchMinSecondsAMD != _generalConfigBackup.SwitchMinSecondsAMD ||
                              ConfigManager.Instance.GeneralConfig.SwitchMinSecondsDynamic != _generalConfigBackup.SwitchMinSecondsDynamic ||
                              ConfigManager.Instance.GeneralConfig.MinerAPIQueryInterval != _generalConfigBackup.MinerAPIQueryInterval;

            if (IsChangeSaved)
            {
                devicesListViewEnableControl1.SaveOptions();
                ConfigManager.Instance.GeneralConfig.Commit();
                ConfigManager.Instance.CommitBenchmarks();
                International.Initialize(ConfigManager.Instance.GeneralConfig.Language);
            }
            else if (IsChange)
            {
                ConfigManager.Instance.GeneralConfig    = _generalConfigBackup;
                ConfigManager.Instance.BenchmarkConfigs = _benchmarkConfigsBackup;
                ConfigManager.Instance.SetDeviceBenchmarkReferences();
            }
        }
Exemple #5
0
        public SettingsViewModel(CommonSettingsModel commonSettingsModel)
        {
            commonSettingsModel.PropertyChanged += Instance_PropertyChanged;
            DefaultButtonCommand = new DelegateCommand <object>(async(c) =>
            {
                var mySetting = new MetroDialogSettings()
                {
                    AffirmativeButtonText = International.GetText("Global_Yes"),
                    NegativeButtonText    = International.GetText("Global_No"),
                    AnimateShow           = true,
                    AnimateHide           = false
                };

                var result = await _dialogCoordinator.ShowMessageAsync(this, International.GetText("Form_Settings_buttonDefaultsTitle"), International.GetText("Form_Settings_buttonDefaultsMsg"), MessageDialogStyle.AffirmativeAndNegative, mySetting);

                if (result == MessageDialogResult.Affirmative)
                {
                    IsChange      = true;
                    IsChangeSaved = true;
                    ConfigManager.GeneralConfig.SetDefaults();

                    International.Initialize(ConfigManager.GeneralConfig.Language);
                }
                CloseWindow((Window)c);
            });
            SaveAndCloseButtonCommand = new DelegateCommand <object>(async(c) =>
            {
                var mySetting = new MetroDialogSettings()
                {
                    AffirmativeButtonText = International.GetText("Global_OK"),
                    AnimateShow           = true,
                    AnimateHide           = false,
                };

                await _dialogCoordinator.ShowMessageAsync(this, International.GetText("Form_Settings_buttonSaveTitle"),
                                                          International.GetText("Form_Settings_buttonSaveMsg"),
                                                          MessageDialogStyle.Affirmative, mySetting);

                IsChange      = true;
                IsChangeSaved = true;
                CloseWindow((Window)c);
            });

            CloseButtonCommand = new DelegateCommand <object>(async(c) =>
            {
                IsChangeSaved = false;
                if (IsChange && !IsChangeSaved)
                {
                    var mySetting = new MetroDialogSettings()
                    {
                        AffirmativeButtonText = International.GetText("Global_Yes"),
                        NegativeButtonText    = International.GetText("Global_No"),
                        AnimateShow           = true,
                        AnimateHide           = false,
                    };

                    var result = await _dialogCoordinator.ShowMessageAsync(this, International.GetText("Form_Settings_buttonCloseNoSaveTitle"), International.GetText("Form_Settings_buttonCloseNoSaveMsg"),
                                                                           MessageDialogStyle.AffirmativeAndNegative, mySetting);

                    if (result == MessageDialogResult.Negative)
                    {
                        return;
                    }
                    else
                    {
                        CloseWindow((Window)c);
                    }
                }
                CloseWindow((Window)c);
            });

            WindowClosing = new DelegateCommand <object>(
                (args) => {
                // check restart parameters change
                IsRestartNeeded = ConfigManager.IsRestartNeeded();

                if (IsChangeSaved)
                {
                    ConfigManager.GeneralConfigFileCommit();
                    ConfigManager.CommitBenchmarks();
                    International.Initialize(ConfigManager.GeneralConfig.Language);
                }
                else
                {
                    ConfigManager.RestoreBackup();
                }
            });
        }