public ApplicationViewModel()
        {
            QuitCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (CanShutdown())
                {
                    if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime
                        desktopLifetime)
                    {
                        desktopLifetime.Shutdown();
                    }
                }
                else
                {
                    // Show the window if it was hidden.
                    ShowRequested?.Invoke(this, EventArgs.Empty);

                    await MainViewModel.Instance !.CompactDialogScreen.NavigateDialogAsync(new Dialogs.ShowErrorDialogViewModel(
                                                                                               "Wasabi is currently anonymising your wallet. Please try again in a few seconds.",
                                                                                               "Warning",
                                                                                               "Unable to close"));
                }
            });

            ShowCommand = ReactiveCommand.Create(() => ShowRequested?.Invoke(this, EventArgs.Empty));
        }
예제 #2
0
        public App()
        {
            Name = "Wasabi Wallet";
            ApplicationViewModel applicationViewModel = new();

            DataContext = applicationViewModel;
            applicationViewModel.ShowRequested += (sender, args) => ShowRequested?.Invoke(sender, args);
        }
    public ApplicationViewModel()
    {
        QuitCommand = ReactiveCommand.CreateFromTask(async() =>
        {
            if (CanShutdown())
            {
                if (Application.Current?.ApplicationLifetime is IControlledApplicationLifetime lifetime)
                {
                    lifetime.Shutdown();
                }
            }
            else
            {
                // Show the window if it was hidden.
                ShowRequested?.Invoke(this, EventArgs.Empty);

                await MainViewModel.Instance.CompactDialogScreen.NavigateDialogAsync(new Dialogs.ShowErrorDialogViewModel(
                                                                                         "Wasabi is currently anonymising your wallet. Please try again in a few minutes.",
                                                                                         "Warning",
                                                                                         "Unable to close right now"));
            }
        });

        ShowCommand = ReactiveCommand.Create(() => ShowRequested?.Invoke(this, EventArgs.Empty));

        var dialogScreen = MainViewModel.Instance.DialogScreen;

        AboutCommand = ReactiveCommand.Create(
            () => dialogScreen.To(new AboutViewModel(navigateBack: dialogScreen.CurrentPage is not null)),
            canExecute: dialogScreen.WhenAnyValue(x => x.CurrentPage)
            .SelectMany(x =>
        {
            return(x switch
            {
                null => Observable.Return(true),
                AboutViewModel => Observable.Return(false),
                _ => x.WhenAnyValue(page => page.IsBusy).Select(isBusy => !isBusy)
            });
        }));
예제 #4
0
 /// <summary>
 /// Raise event.
 /// </summary>
 /// <remarks>
 /// This method is intended to be called by an instance other than that instantiated this object.
 /// </remarks>
 public void RaiseShowRequested()
 {
     ShowRequested?.Invoke(this, EventArgs.Empty);
 }
예제 #5
0
 public void ShowView()
 {
     ShowRequested?.Invoke();
 }
예제 #6
0
 /// <summary>
 /// Raise event.
 /// </summary>
 /// <remarks>
 /// This method is intended to be called by an instance other than that instantiated this object.
 /// </remarks>
 public void RaiseShowRequested()
 {
     ShowRequested?.Invoke(this, null);
 }
예제 #7
0
 public void ShowRequest()
 {
     // This method will be called by an instance other than one which instantiated this object.
     App.Current.Dispatcher.Invoke(() => ShowRequested?.Invoke(this, null));
 }