|
@@ -1,25 +1,15 @@
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
-using System.IO;
|
|
|
|
-using System.Net.Http;
|
|
|
|
-using System.Reactive;
|
|
|
|
-using System.Reactive.Disposables;
|
|
|
|
-using System.Reactive.Linq;
|
|
|
|
-using System.Text;
|
|
|
|
-using System.Windows;
|
|
|
|
-using System.Windows.Media;
|
|
|
|
using Avalonia;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls;
|
|
|
|
+using CommunityToolkit.Mvvm.Input;
|
|
using PixiEditor.Avalonia.ViewModels;
|
|
using PixiEditor.Avalonia.ViewModels;
|
|
using PixiEditor.Avalonia.Views;
|
|
using PixiEditor.Avalonia.Views;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Models.DataHolders;
|
|
-using PixiEditor.Views;
|
|
|
|
-using PixiEditor.Views.Dialogs;
|
|
|
|
-using ReactiveUI;
|
|
|
|
|
|
|
|
namespace PixiEditor.ViewModels;
|
|
namespace PixiEditor.ViewModels;
|
|
|
|
|
|
-internal class CrashReportViewModel : ViewModelBase
|
|
|
|
|
|
+internal partial class CrashReportViewModel : ViewModelBase
|
|
{
|
|
{
|
|
private bool hasRecoveredDocuments = true;
|
|
private bool hasRecoveredDocuments = true;
|
|
|
|
|
|
@@ -29,12 +19,6 @@ internal class CrashReportViewModel : ViewModelBase
|
|
|
|
|
|
public int DocumentCount { get; }
|
|
public int DocumentCount { get; }
|
|
|
|
|
|
- public ReactiveCommand<Unit, Unit> OpenSendCrashReportCommand { get; }
|
|
|
|
-
|
|
|
|
- public ReactiveCommand<Unit, Unit> RecoverDocumentsCommand { get; }
|
|
|
|
-
|
|
|
|
- public ReactiveCommand<Unit, Unit> AttachDebuggerCommand { get; }
|
|
|
|
-
|
|
|
|
public bool IsDebugBuild { get; set; }
|
|
public bool IsDebugBuild { get; set; }
|
|
|
|
|
|
public CrashReportViewModel(CrashReport report)
|
|
public CrashReportViewModel(CrashReport report)
|
|
@@ -46,19 +30,12 @@ internal class CrashReportViewModel : ViewModelBase
|
|
DocumentCount = report.GetDocumentCount();
|
|
DocumentCount = report.GetDocumentCount();
|
|
//TODO: Implement
|
|
//TODO: Implement
|
|
//OpenSendCrashReportCommand = ReactiveCommand.Create(() => new SendCrashReportWindow(CrashReport).Show());
|
|
//OpenSendCrashReportCommand = ReactiveCommand.Create(() => new SendCrashReportWindow(CrashReport).Show());
|
|
- RecoverDocumentsCommand = ReactiveCommand.Create(RecoverDocuments, Observable.Create((IObserver<bool> observer) =>
|
|
|
|
- {
|
|
|
|
- observer.OnNext(hasRecoveredDocuments);
|
|
|
|
- observer.OnCompleted();
|
|
|
|
- return Disposable.Empty;
|
|
|
|
- }));
|
|
|
|
-
|
|
|
|
- AttachDebuggerCommand = ReactiveCommand.Create(AttachDebugger);
|
|
|
|
|
|
|
|
if (!IsDebugBuild)
|
|
if (!IsDebugBuild)
|
|
_ = CrashHelper.SendReportTextToWebhook(report);
|
|
_ = CrashHelper.SendReportTextToWebhook(report);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [RelayCommand(CanExecute = nameof(CanRecoverDocuments))]
|
|
public void RecoverDocuments()
|
|
public void RecoverDocuments()
|
|
{
|
|
{
|
|
MainWindow window = MainWindow.CreateWithDocuments(CrashReport.RecoverDocuments());
|
|
MainWindow window = MainWindow.CreateWithDocuments(CrashReport.RecoverDocuments());
|
|
@@ -68,12 +45,18 @@ internal class CrashReportViewModel : ViewModelBase
|
|
hasRecoveredDocuments = false;
|
|
hasRecoveredDocuments = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public bool CanRecoverDocuments()
|
|
|
|
+ {
|
|
|
|
+ return hasRecoveredDocuments;
|
|
|
|
+ }
|
|
|
|
+
|
|
[Conditional("DEBUG")]
|
|
[Conditional("DEBUG")]
|
|
private void SetIsDebug()
|
|
private void SetIsDebug()
|
|
{
|
|
{
|
|
IsDebugBuild = true;
|
|
IsDebugBuild = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [RelayCommand]
|
|
private void AttachDebugger()
|
|
private void AttachDebugger()
|
|
{
|
|
{
|
|
if (!Debugger.Launch())
|
|
if (!Debugger.Launch())
|