예제 #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);
        }
예제 #2
0
 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);
     }
 }
예제 #3
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);
            }
        }
예제 #4
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);
            }
        }
        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);
            }
        }
예제 #6
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);
         });
     }
 }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #13
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);
        }
 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);
         }
     }
 }
예제 #15
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);
                }
            }
        }