Example #1
0
        private void CreateBugUUIDDialog(string uuid, bool success)
        {
            var bugUUIDDialog = new CustomDialog();

            if (success)
            {
                bugUUIDDialog.Title            = "Bug report ID";
                bugUUIDDialog.Description      = Translations.Tr("Use following ID for bug reporting.\n{0}", uuid);
                bugUUIDDialog.OkText           = Translations.Tr("Copy to clipboard");
                bugUUIDDialog.CancelVisible    = Visibility.Collapsed;
                bugUUIDDialog.CloseOnOk        = false;
                bugUUIDDialog.AnimationVisible = Visibility.Collapsed;
                bugUUIDDialog.OKClick         += (s, e) => Clipboard.SetText(uuid);
            }
            else
            {
                bugUUIDDialog.Title            = "Bug report failed";
                bugUUIDDialog.Description      = Translations.Tr("Bug report has failed. Please contact our support agent for help.");
                bugUUIDDialog.OkText           = Translations.Tr("OK");
                bugUUIDDialog.CancelVisible    = Visibility.Collapsed;
                bugUUIDDialog.AnimationVisible = Visibility.Collapsed;
            }

            CustomDialogManager.ShowModalDialog(bugUUIDDialog);
        }
        private void OnAcceptOrDecline(object sender, RoutedEventArgs e)
        {
            _pluginsToAccept--;
            if (_pluginsToAccept == 0)
            {
                CustomDialogManager.HideCurrentModal();
                var nhmRestartDialog = new CustomDialog()
                {
                    Title            = Tr("Restart NiceHash Miner"),
                    Description      = Tr("NiceHash Miner restart is required."),
                    OkText           = Tr("Restart"),
                    AnimationVisible = Visibility.Collapsed,
                    CancelVisible    = Visibility.Collapsed,
                    ExitVisible      = Visibility.Collapsed,
                };
                nhmRestartDialog.OKClick += (s, e1) => {
                    Task.Run(() => ApplicationStateManager.RestartProgram());
                };
                CustomDialogManager.ShowModalDialog(nhmRestartDialog);

                var nhmRestartingDialog = new CustomDialog()
                {
                    Title            = Tr("NiceHash Miner Restarting"),
                    Description      = Tr("NiceHash Miner restart in progress."),
                    CancelVisible    = Visibility.Collapsed,
                    OkVisible        = Visibility.Collapsed,
                    AnimationVisible = Visibility.Visible,
                    ExitVisible      = Visibility.Collapsed
                };
                CustomDialogManager.ShowModalDialog(nhmRestartingDialog);
            }
        }
Example #3
0
        private void AESStringDecrypt_OnClick(object sender, RoutedEventArgs e)
        {
            var text = AESEncryptText.Text;

            if (Salt.Text.Length != 16 && Salt.Text.Length != 24 && Salt.Text.Length != 32)
            {
                var errorMessageShow = new CustomDialog()
                {
                    Title            = "Lỗi!",
                    Description      = "Salt phải là 16 bit, 24 bit hoặc 32 bit!",
                    OkText           = "Được",
                    AnimationVisible = Visibility.Collapsed
                };
                CustomDialogManager.ShowModalDialog(errorMessageShow);
                return;
            }
            aesStringInstance = new AESStringEngine(Salt.Text, config.IVKey);
            try
            {
                usageCheck.AESDeStringDone();
                AESResults.Text = aesStringInstance.Decrypt(text);
            } catch (Exception err)
            {
                AESResults.Text = "";
                var errorMessageShow = new CustomDialog()
                {
                    Title            = "Lỗi!",
                    Description      = "Chi tiết lỗi: " + err,
                    OkText           = "Được",
                    AnimationVisible = Visibility.Collapsed
                };
                CustomDialogManager.ShowModalDialog(errorMessageShow);
            }
        }
Example #4
0
        private void AESStringDecrypt_OnClick(object sender, RoutedEventArgs e)
        {
            var text = txtFile;

            if (Salt.Text.Length != 16 && Salt.Text.Length != 24 && Salt.Text.Length != 32)
            {
                var errorMessageShow = new CustomDialog()
                {
                    Title            = "Lỗi!",
                    Description      = "Salt phải là 16 bit, 24 bit hoặc 32 bit!",
                    OkText           = "Được",
                    AnimationVisible = Visibility.Collapsed
                };
                CustomDialogManager.ShowModalDialog(errorMessageShow);
                return;
            }
            aesStringInstance = new AESStringEngine(Salt.Text, config.IVKey);
            try
            {
                if (usage.file_usage < config.limitAESFile)
                {
                    usageCheck.AESDeFileDone();
                    AESResults.Text = aesStringInstance.Decrypt(text);
                }
                else
                {
                    var errorMessageShow = new CustomDialog()
                    {
                        Title            = "Lỗi!",
                        Description      = "Bạn đã đạt giới hạn!",
                        OkText           = "Được",
                        AnimationVisible = Visibility.Collapsed
                    };
                    CustomDialogManager.ShowModalDialog(errorMessageShow);
                }
            }
            catch (CryptographicException err)
            {
                AESResults.Text = "";
                var errorMessageShow = new CustomDialog()
                {
                    Title            = "Lỗi!",
                    Description      = "Độ lớn của dữ liệu giải mã không hợp lệ!",
                    OkText           = "Được",
                    AnimationVisible = Visibility.Collapsed
                };
            }
            catch (Exception err)
            {
                AESResults.Text = "";
                var errorMessageShow = new CustomDialog()
                {
                    Title            = "Lỗi!",
                    Description      = "Chi tiết lỗi: " + err,
                    OkText           = "Được",
                    AnimationVisible = Visibility.Collapsed
                };
                CustomDialogManager.ShowModalDialog(errorMessageShow);
            }
        }
 private async void Button_Click_Install(object sender, RoutedEventArgs e)
 {
     if (_vm.Load.IsInstalling)
     {
         return;
     }
     if (AcceptedPlugins.IsAccepted(_vm.Plugin.PluginUUID))
     {
         await _vm.InstallOrUpdatePlugin();
     }
     else
     {
         var dialog = new CustomDialog(400, 300)
         {
             // Translate this???
             Title            = "Disclaimer on usage of 3rd party software",
             Description      = "NiceHash Miner integrates 3rd party mining software via the miner plugin system. However, since this is 3rd party software that is fully closed-source, we have no chance to inspect it in any way. NiceHash can not vouch for using that software and is refusing to take any responsibility for any damage caused, security breaches, loss of data or funds, system or hardware error, and other issues. By agreeing to this disclaimer you take full responsibility for using these closed-source miners as they are.",
             OkText           = Tr("I ACCEPT"),
             CancelText       = Tr("CANCEL"),
             AnimationVisible = Visibility.Collapsed
         };
         dialog.OKClick += async(s, e1) =>
         {
             AcceptedPlugins.Add(_vm.Plugin.PluginUUID);
             await _vm.InstallOrUpdatePlugin();
         };
         CustomDialogManager.ShowModalDialog(dialog);
     }
 }
 private void OnAcceptOrDecline(object sender, RoutedEventArgs e)
 {
     _pluginsToAccept--;
     if (_pluginsToAccept == 0)
     {
         CustomDialogManager.HideCurrentModal();
     }
 }
        private void PluginsConfirmDialog_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var vm = e.NewValue as VM;

            _pluginsToAccept = vm?.Plugins?.Count() ?? 0;
            if (_pluginsToAccept == 0)
            {
                CustomDialogManager.HideCurrentModal();
            }
        }
Example #8
0
 private void MiningStateInstance_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (nameof(MiningState.Instance.IsDemoMining) == e.PropertyName && MiningState.Instance.IsDemoMining)
     {
         Dispatcher.Invoke(() =>
         {
             var demoMiningDialog = new EnterWalletDialogDemo();
             CustomDialogManager.ShowModalDialog(demoMiningDialog);
         });
     }
 }
        public AlgorithmItem()
        {
            InitializeComponent();
#if USE_MODAL
            _algorithmSettings             = new AlgorithmSettings();
            _algorithmSettings.MaxWidth    = 392;
            _algorithmSettings.MaxHeight   = 798;
            _algorithmSettings.CloseClick += (s, e) => CustomDialogManager.HideCurrentModal();
#endif

            DataContextChanged += AlgorithmItem_DataContextChanged;
        }
Example #10
0
        private void Button_Click_ClearAllSpeeds(object sender, RoutedEventArgs e)
        {
            var nhmConfirmDialog = new CustomDialog()
            {
                Title       = Tr("Set default settings?"),
                Description = Tr("Are you sure you would like to clear all speeds for {0}?", _deviceData.Dev.FullName),
                OkText      = Tr("Yes"),
                CancelText  = Tr("No")
            };

            DeviceActionsButtonContext.IsOpen = false;
            nhmConfirmDialog.OKClick         += (s, e1) => { _deviceData.ClearAllSpeeds(); };
            CustomDialogManager.ShowModalDialog(nhmConfirmDialog);
        }
Example #11
0
        private void CreateLogReportButton_Click(object sender, RoutedEventArgs e)
        {
            var nhmConfirmDialog = new CustomDialog()
            {
                Title            = Translations.Tr("Pack and upload log files?"),
                Description      = Translations.Tr("This will upload log report to our server."),
                OkText           = Translations.Tr("Ok"),
                CancelText       = Translations.Tr("Cancel"),
                AnimationVisible = Visibility.Collapsed
            };

            nhmConfirmDialog.OKClick += (s, e1) => ProcessLogReport();
            CustomDialogManager.ShowModalDialog(nhmConfirmDialog);
        }
Example #12
0
        private void CreateBugUUIDDialog(string uuid)
        {
            var bugUUIDDialog = new CustomDialog()
            {
                Title            = Translations.Tr("Bug report uuid"),
                Description      = Translations.Tr("Use following UUID for bug reporting.\n{0}", uuid),
                OkText           = Translations.Tr("Copy to clipboard"),
                CancelVisible    = Visibility.Collapsed,
                AnimationVisible = Visibility.Collapsed
            };

            bugUUIDDialog.OKClick += (s, e) => Clipboard.SetText(uuid);
            CustomDialogManager.ShowModalDialog(bugUUIDDialog);
        }
Example #13
0
        private void Button_Click_ClearAllSpeeds(object sender, RoutedEventArgs e)
        {
            TryCloseParentContextMenu();
            var nhmConfirmDialog = new CustomDialog()
            {
                Title            = Tr("Set default settings?"),
                Description      = Tr("Are you sure you would like to clear all speeds for {0}?", _deviceData.Dev.FullName),
                OkText           = Tr("Yes"),
                CancelText       = Tr("No"),
                AnimationVisible = Visibility.Collapsed
            };


            nhmConfirmDialog.OKClick += (s, e1) => { _deviceData.ClearAllSpeeds(); };
            CustomDialogManager.ShowModalDialog(nhmConfirmDialog);
        }
Example #14
0
        private void LanguageComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var nhmConfirmDialog = new CustomDialog()
            {
                Title            = Translations.Tr("Language change"),
                Description      = Translations.Tr("Your program will be restarted in order to completely change the language of NiceHash Miner."),
                OkText           = Translations.Tr("Ok"),
                CancelVisible    = Visibility.Collapsed,
                AnimationVisible = Visibility.Collapsed
            };

            nhmConfirmDialog.OKClick += (s, e1) => CommitGeneralAndRestart();
            nhmConfirmDialog.OnExit  += (s, e1) => CommitGeneralAndRestart();

            CustomDialogManager.ShowModalDialog(nhmConfirmDialog);
        }
        private void CreateLogReportButton_Click(object sender, RoutedEventArgs e)
        {
            var nhmConfirmDialog = new CustomDialog()
            {
                Title       = Translations.Tr("Pack log files?"),
                Description = Translations.Tr("This will restart your program and create a zip file on Desktop."),
                OkText      = Translations.Tr("Ok"),
                CancelText  = Translations.Tr("Cancel")
            };

            nhmConfirmDialog.OKClick += (s, e1) =>
            {
                File.Create(Paths.RootPath("do.createLog"));
                Task.Run(() => ApplicationStateManager.RestartProgram());
            };
            CustomDialogManager.ShowModalDialog(nhmConfirmDialog);
        }
Example #16
0
        private void Btn_default_Click(object sender, RoutedEventArgs e)
        {
            var nhmConfirmDialog = new CustomDialog()
            {
                Title       = Tr("Set default settings?"),
                Description = Tr("Are you sure you would like to set everything back to defaults? This will restart NiceHash Miner automatically."),
                OkText      = Tr("Yes"),
                CancelText  = Tr("No")
            };

            nhmConfirmDialog.OKClick += (s, e1) => {
                Translations.SelectedLanguage = "en";
                ConfigManager.SetDefaults();
                Task.Run(() => ApplicationStateManager.RestartProgram());
            };
            CustomDialogManager.ShowModalDialog(nhmConfirmDialog);
        }
Example #17
0
        private async void SaveButtonClicked(object sender, RoutedEventArgs e)
        {
            var trimmedBtcText = textBoxBTCAddress.Text.Trim();
            var result         = await ApplicationStateManager.SetBTCIfValidOrDifferent(trimmedBtcText);

            if (ApplicationStateManager.SetResult.INVALID == result)
            {
                textBoxBTCAddress.Style       = Application.Current.FindResource("InputBoxBad") as Style;
                textBoxBTCAddress.BorderBrush = (Brush)Application.Current.FindResource("RedDangerColorBrush");
            }
            else
            {
                CustomDialogManager.HideCurrentModal();
                textBoxBTCAddress.Style       = Application.Current.FindResource("InputBoxGood") as Style;
                textBoxBTCAddress.BorderBrush = (Brush)Application.Current.FindResource("NastyGreenBrush");
            }
        }
 private void CheckConnection(object sender, ElapsedEventArgs e)
 {
     if (!_vm.NHMWSConnected && !nhmwsDialogShown)
     {
         try
         {
             Dispatcher.Invoke(() =>
             {
                 var dialog = new CustomDialog
                 {
                     Title            = Translations.Tr("NHMWS not connected"),
                     Description      = Translations.Tr("Not connected to NHMWS. Please check your internet connection."),
                     CancelVisible    = Visibility.Collapsed,
                     OkVisible        = Visibility.Collapsed,
                     AnimationVisible = Visibility.Collapsed,
                 };
                 CustomDialogManager.ShowModalDialog(dialog);
             });
             nhmwsDialogShown = true;
             _timer.Stop();
             _timer.Interval = 1000;
             _timer.Start();
         }
         catch (Exception ex)
         {
             Logger.Error("MainVM.IsNHMWSConnected", ex.Message);
         }
     }
     else if (_vm.NHMWSConnected && nhmwsDialogShown)
     {
         try
         {
             Dispatcher.Invoke(() => CustomDialogManager.HideCurrentModal());
             nhmwsDialogShown = false;
             _timer.Stop();
             _timer.Interval = 1000 * 60 * 2; //2min
             _timer.Start();
         }
         catch (Exception ex)
         {
             _timer.Stop();
             Logger.Error("MainVM.IsNHMWSConnected", ex.Message);
         }
     }
 }
Example #19
0
        private void SaveButtonClicked(object sender, RoutedEventArgs e)
        {
            var trimmedWorkernameText = textBoxWorkername.Text.Trim();
            var result = ApplicationStateManager.SetWorkerIfValidOrDifferent(trimmedWorkernameText);

            if (ApplicationStateManager.SetResult.INVALID == result)
            {
                textBoxWorkername.Style       = Application.Current.FindResource("InputBoxBad") as Style;
                textBoxWorkername.BorderBrush = (Brush)Application.Current.FindResource("RedDangerColorBrush");
            }
            else
            {
                CustomDialogManager.HideCurrentModal();
                textBoxWorkername.Style       = Application.Current.FindResource("InputBoxGood") as Style;
                textBoxWorkername.BorderBrush = (Brush)Application.Current.FindResource("NastyGreenBrush");
                OnWorkernameChangeHack?.Invoke(this, trimmedWorkernameText);
            }
        }
        private void AlgorithmSettings_Button_Click(object sender, RoutedEventArgs e)
        {
#if USE_MODAL
            CustomDialogManager.ShowDialog(_algorithmSettings);
#else
            if (sender is Button tButton && !_toggleButtonsGuard.Contains(tButton))
            {
                _toggleButtonsGuard.Add(tButton);
                AlgorithmSettingsContextMenu.IsOpen = true;
                RoutedEventHandler closedHandler = null;
                closedHandler += (s, e2) =>
                {
                    _toggleButtonsGuard.Remove(tButton);
                    //tButton.IsChecked = false;
                    AlgorithmSettingsContextMenu.Closed -= closedHandler;
                };
                AlgorithmSettingsContextMenu.Closed += closedHandler;
            }
#endif
        }
Example #21
0
 private void CloseDialog(object sender, RoutedEventArgs e)
 {
     CustomDialogManager.HideCurrentModal();
     OnExit?.Invoke(this, e);
 }
Example #22
0
 private void CloseDialog(object sender, RoutedEventArgs e)
 {
     CustomDialogManager.HideCurrentModal();
 }
Example #23
0
 private void Click_ChangeWorkername(object sender, RoutedEventArgs e)
 {
     CustomDialogManager.ShowDialog(_enterWorkernameDialog);
 }
Example #24
0
 private void EnterBTCWallet_Button_Click(object sender, RoutedEventArgs e)
 {
     CustomDialogManager.ShowDialog(_enterBTCAddress);
 }
Example #25
0
        // just in case we add more awaits this signature will await all of them
        private async Task MainWindow_OnLoadedTask()
        {
            try
            {
                await _vm.InitializeNhm(LoadingBar.StartupLoader);
            }
            finally
            {
                LoadingBar.Visibility = Visibility.Collapsed;
                // Re-enable managed controls
                IsEnabled = true;
                SetTabButtonsEnabled();
                if (BuildOptions.SHOW_TDP_SETTINGS)
                {
                    var tdpWindow = new TDPSettingsWindow();
                    tdpWindow.DataContext = _vm;
                    tdpWindow.Show();
                }

                if (MinerPluginsManager.EulaConfirm.Any())
                {
                    var pluginsPopup = new Plugins.PluginsConfirmDialog();
                    pluginsPopup.DataContext = new Plugins.PluginsConfirmDialog.VM
                    {
                        Plugins = new ObservableCollection <PluginPackageInfoCR>(MinerPluginsManager.EulaConfirm)
                    };
                    ShowContentAsModalDialog(pluginsPopup);
                }

                if (LoginSuccess.HasValue)
                {
                    var description    = LoginSuccess.Value ? Translations.Tr("Login performed successfully.") : Translations.Tr("Unable to retreive BTC address. Please retreive it by yourself from web page.");
                    var btcLoginDialog = new CustomDialog()
                    {
                        Title            = Translations.Tr("Login"),
                        OkText           = Translations.Tr("Ok"),
                        CancelVisible    = Visibility.Collapsed,
                        AnimationVisible = Visibility.Collapsed,
                        Description      = description
                    };
                    btcLoginDialog.OKClick += (s, e) =>
                    {
                        if (!LoginSuccess.Value)
                        {
                            Process.Start(Links.Login);
                        }
                    };
                    CustomDialogManager.ShowModalDialog(btcLoginDialog);
                }

                if (Launcher.IsUpdated)
                {
                    var nhmUpdatedDialog = new CustomDialog()
                    {
                        Title            = Translations.Tr("NiceHash Miner Updated"),
                        Description      = Translations.Tr("Completed NiceHash Miner auto update."),
                        OkText           = Translations.Tr("OK"),
                        CancelVisible    = Visibility.Collapsed,
                        AnimationVisible = Visibility.Collapsed
                    };
                    ShowContentAsModalDialog(nhmUpdatedDialog);
                }

                if (Launcher.IsUpdatedFailed)
                {
                    var nhmUpdatedDialog = new CustomDialog()
                    {
                        Title            = Translations.Tr("NiceHash Miner Autoupdate Failed"),
                        Description      = Translations.Tr("NiceHash Miner auto update failed to complete. Autoupdates are disabled until next miner launch."),
                        OkText           = Translations.Tr("OK"),
                        CancelVisible    = Visibility.Collapsed,
                        AnimationVisible = Visibility.Collapsed
                    };
                    ShowContentAsModalDialog(nhmUpdatedDialog);
                }
            }
        }
        private async Task EvalTimer_ElapsedTask()
        {
            using (var tryLock = new TryLock(_lock))
            {
                if (!tryLock.HasAcquiredLock)
                {
                    return;
                }
                try
                {
#warning handle case for logged in sessions with/without btc
                    string html = await browser.InvokeScriptAsync("eval", new string[] { "document.getElementById('nhmResponse').value;" });

                    var webResponse = JsonConvert.DeserializeObject <Response>(html);
                    if (webResponse == null)
                    {
                        return;
                    }

                    // assume failure
                    var description = Translations.Tr("Unable to retreive BTC address. Please retreive it by yourself from web page.");

                    if (webResponse.btcAddress != null)
                    {
                        var result = await ApplicationStateManager.SetBTCIfValidOrDifferent(webResponse.btcAddress);

                        if (result == ApplicationStateManager.SetResult.CHANGED)
                        {
                            description = Translations.Tr("Login performed successfully.");
                            Logger.Info("Login", $"Navigation and processing successfull.");
                        }
                        else
                        {
                            Logger.Error("Login", $"Btc address: {webResponse.btcAddress} was not saved. Result: {result}.");
                        }
                    }
                    else if (webResponse.error != null)
                    {
                        var error = webResponse.error;
                        Logger.Error("Login", "Received error: " + error);
                    }
                    else
                    {
                        Logger.Info("Login", $"Navigation and processing successfull. BTC wasn't retreived.");
                    }

                    var btcLoginDialog = new CustomDialog()
                    {
                        Title            = Translations.Tr("Login"),
                        OkText           = Translations.Tr("Ok"),
                        CancelVisible    = Visibility.Collapsed,
                        AnimationVisible = Visibility.Collapsed,
                        Description      = description
                    };
                    btcLoginDialog.OKClick += (s, e) =>
                    {
                        Process.Start(Links.Login);
                    };

                    CustomDialogManager.ShowModalDialog(btcLoginDialog);

                    _evalTimer.Dispose();
                    Close();
                }
                catch (Exception e)
                {
                    Logger.Error("Login", e.Message);
                }
            }
        }
        private async Task EvalTimer_ElapsedTask()
        {
            using (var tryLock = new TryLock(_lock))
            {
                if (!tryLock.HasAcquiredLock)
                {
                    return;
                }
                try
                {
                    string html = await browser.InvokeScriptAsync("eval", new string[] { "document.getElementById('nhmResponse').value;" });

                    if (!html.Contains("btcAddress"))
                    {
                        return;
                    }
                    var btcResp = JsonConvert.DeserializeObject <BtcResponse>(html);
                    if (btcResp.btcAddress != null)
                    {
                        var result = await ApplicationStateManager.SetBTCIfValidOrDifferent(btcResp.btcAddress);

                        var btcLoginDialog = new CustomDialog()
                        {
                            Title            = Translations.Tr("Login"),
                            OkText           = Translations.Tr("Ok"),
                            CancelVisible    = Visibility.Collapsed,
                            AnimationVisible = Visibility.Collapsed
                        };

                        if (result == ApplicationStateManager.SetResult.INVALID)
                        {
                            btcLoginDialog.Description = Translations.Tr("Unable to retreive BTC address. Please retreive it by yourself from web page.");
                            btcLoginDialog.OKClick    += (s, e) => {
                                Process.Start(Links.Login);
                            };
                        }
                        else if (result == ApplicationStateManager.SetResult.CHANGED)
                        {
                            btcLoginDialog.Description = Translations.Tr("Login performed successfully. Feel free to start mining.");
                        }

                        CustomDialogManager.ShowModalDialog(btcLoginDialog);
                    }
                    else
                    {
                        var btcLoginDialog = new CustomDialog()
                        {
                            Title            = Translations.Tr("Login"),
                            OkText           = Translations.Tr("Ok"),
                            CancelVisible    = Visibility.Collapsed,
                            AnimationVisible = Visibility.Collapsed,
                            Description      = Translations.Tr("Unable to retreive BTC address. Please retreive it by yourself from web page.")
                        };
                        btcLoginDialog.OKClick += (s, e) => {
                            Process.Start(Links.Login);
                        };
                        CustomDialogManager.ShowModalDialog(btcLoginDialog);
                    }
                    _evalTimer.Dispose();
                    Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }