コード例 #1
0
ファイル: App.xaml.cs プロジェクト: vGimly/LibgenDesktop
        private void ShowErrorWindow(Exception exception)
        {
            Logger.Exception(exception);
            ErrorWindowViewModel errorWindowViewModel = new ErrorWindowViewModel(exception?.ToString() ?? "(null)");
            IWindowContext       errorWindowContext   = WindowManager.CreateWindow(RegisteredWindows.WindowKey.ERROR_WINDOW, errorWindowViewModel);

            errorWindowContext.ShowDialog();
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ErrorWindow"/> class.
        /// </summary>
        /// <param name="vm">ViewModel for error window.</param>
        public ErrorWindow(ErrorWindowViewModel vm)
        {
            InitializeComponent();

            _vm = vm;

            DataContext = _vm;
        }
コード例 #3
0
        /// <summary>
        /// Shows error window for uncaught exceptions. Closes application once
        /// the error window is closed.
        /// </summary>
        /// <param name="ex">Exception to display.</param>
        /// <param name="source">Source of exception.</param>
        private void ShowUnhandledException(Exception ex, string source)
        {
            var ewvm = new ErrorWindowViewModel($"Unhandled exception in application: {source}", ex)
            {
                ExitOnClose = true,
            };

            Workspace.RecreateSingletonWindow <ErrorWindow>(ewvm);
        }
コード例 #4
0
        private CustomMessageBox()
        {
            InitializeComponent();

            DiscordButton.Click += Util.OpenDiscord;
            DataContext          = new ErrorWindowViewModel();

            Activate();
            Topmost = true;
            Topmost = false;
            Focus();
        }
コード例 #5
0
        public ErrorNotificationWindow(string message, string title, string acceptButtonTitle)
        {
            InitializeComponent();

            var vm = new ErrorWindowViewModel();

            vm.Title.Text        = title;
            vm.Message.Text      = message;
            vm.AcceptButton.Text = acceptButtonTitle ?? "Ok";

            ViewModel = vm;
        }
コード例 #6
0
        public ErrorWindow(Exception exc, string message, string context)
        {
            InitializeComponent();

            DiscordButton.Click += Util.OpenDiscord;
            DataContext          = new ErrorWindowViewModel();

            ExceptionTextBox.AppendText(exc.ToString());
            ExceptionTextBox.AppendText("\nVersion: " + Util.GetAssemblyVersion());
            ExceptionTextBox.AppendText("\nGit Hash: " + Util.GetGitHash());
            ExceptionTextBox.AppendText("\nContext: " + context);
            ExceptionTextBox.AppendText("\nOS: " + Environment.OSVersion);
            ExceptionTextBox.AppendText("\n64bit? " + Environment.Is64BitProcess);

            if (App.Settings != null)
            {
                ExceptionTextBox.AppendText("\nDX11? " + App.Settings.IsDx11);
                ExceptionTextBox.AppendText("\nAddons Enabled? " + App.Settings.InGameAddonEnabled);
                ExceptionTextBox.AppendText("\nAuto Login Enabled? " + App.Settings.AutologinEnabled);
                ExceptionTextBox.AppendText("\nLanguage: " + App.Settings.Language);
                ExceptionTextBox.AppendText("\nGame path: " + App.Settings.GamePath);

                // When this happens we probably don't want them to run into it again, in case it's an issue with a moved game for example
                App.Settings.AutologinEnabled = false;
            }

#if DEBUG
            ExceptionTextBox.AppendText("\nDebugging");
#endif

            ExceptionTextBox.AppendText("\n\n\nAddons: " + Properties.Settings.Default.Addons);

            ContextTextBlock.Text = message;

            Serilog.Log.Error("ErrorWindow called: [{0}] [{1}]\n" + new TextRange(ExceptionTextBox.Document.ContentStart, ExceptionTextBox.Document.ContentEnd).Text, message, context);

            SystemSounds.Hand.Play();

            Activate();
            Topmost = true;
            Topmost = false;
            Focus();
        }
コード例 #7
0
ファイル: App.xaml.cs プロジェクト: zzmjohn/LibgenDesktop
 private void ShowErrorWindow(Exception exception)
 {
     if (!Dispatcher.CheckAccess())
     {
         Dispatcher.Invoke(() => ShowErrorWindow(exception));
     }
     else
     {
         Logger.Exception(exception);
         try
         {
             ErrorWindowViewModel errorWindowViewModel = new ErrorWindowViewModel(exception?.ToString() ?? "(null)",
                                                                                  mainModel?.Localization?.CurrentLanguage);
             IWindowContext errorWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.ERROR_WINDOW, errorWindowViewModel);
             errorWindowContext.ShowDialog();
         }
         catch (Exception errorWindowException)
         {
             Logger.Exception(errorWindowException);
         }
     }
 }
コード例 #8
0
 public SendMessageCommand(ErrorWindowViewModel viewModel)
 {
     _viewModel = viewModel;
 }
コード例 #9
0
 public ErrorWindow(Task problemTask)
 {
     InitializeComponent();
     DataContext = new ErrorWindowViewModel(problemTask);
 }
コード例 #10
0
 public ErrorWindow(Exception exception)
 {
     InitializeComponent();
     DataContext = new ErrorWindowViewModel(exception);
 }