|
@@ -1,11 +1,7 @@
|
|
|
-using System.Reactive;
|
|
|
-using System.Reactive.Disposables;
|
|
|
-using System.Reactive.Linq;
|
|
|
+using System.Windows.Input;
|
|
|
using Avalonia.Controls;
|
|
|
using Avalonia.Markup.Xaml;
|
|
|
-using Microsoft.Extensions.DependencyInjection;
|
|
|
using PixiEditor.Helpers;
|
|
|
-using ReactiveUI;
|
|
|
|
|
|
namespace PixiEditor.Models.Commands.XAML;
|
|
|
|
|
@@ -48,57 +44,28 @@ internal class Command : MarkupExtension
|
|
|
return GetPixiCommand ? command : GetICommand(command, UseProvided);
|
|
|
}
|
|
|
|
|
|
- public static IReactiveCommand GetICommand(Commands.Command command, bool useProvidedParameter) => new ProvidedICommand()
|
|
|
+ public static ICommand GetICommand(Commands.Command command, bool useProvidedParameter) => new ProvidedICommand()
|
|
|
{
|
|
|
Command = command,
|
|
|
UseProvidedParameter = useProvidedParameter,
|
|
|
};
|
|
|
|
|
|
- class ProvidedICommand : IReactiveCommand
|
|
|
+ class ProvidedICommand : ICommand
|
|
|
{
|
|
|
//TODO: Not found in Avalonia
|
|
|
-
|
|
|
- /*public event EventHandler CanExecuteChanged
|
|
|
- {
|
|
|
- add => CommandManager.RequerySuggested += value;
|
|
|
- remove => CommandManager.RequerySuggested -= value;
|
|
|
- }*/
|
|
|
+ public event EventHandler? CanExecuteChanged;
|
|
|
+ /* {
|
|
|
+ add => CommandManager.RequerySuggested += value;
|
|
|
+ remove => CommandManager.RequerySuggested -= value;
|
|
|
+ }*/
|
|
|
|
|
|
public Commands.Command Command { get; init; }
|
|
|
|
|
|
public bool UseProvidedParameter { get; init; }
|
|
|
|
|
|
- public IObservable<Exception> ThrownExceptions { get; }
|
|
|
-
|
|
|
- public IObservable<bool> IsExecuting { get; }
|
|
|
-
|
|
|
- public IObservable<bool> CanExecute { get; }
|
|
|
-
|
|
|
- public ProvidedICommand()
|
|
|
- {
|
|
|
- ReactiveCommand<object, Unit> reactiveCommand = ReactiveCommand.Create<object, Unit>(Execute, CanExecuteCommand());
|
|
|
- }
|
|
|
-
|
|
|
+ public bool CanExecute(object parameter) => UseProvidedParameter ? Command.Methods.CanExecute(parameter) : Command.CanExecute();
|
|
|
|
|
|
- public IObservable<bool> CanExecuteCommand()
|
|
|
- {
|
|
|
- return this.WhenAnyValue(x => x.Command, x => x.UseProvidedParameter, (command, useProvidedParameter) =>
|
|
|
- {
|
|
|
- return true;
|
|
|
- /*if (useProvidedParameter)
|
|
|
- {
|
|
|
- return command.CanExecute();
|
|
|
- //TODO: return command.CanExecute(parameter); // Should be this, but idk how to make it properly, I think whole logic should be changed so it fits
|
|
|
- // reactiveUI
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return command.CanExecute();
|
|
|
- }*/
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- public Unit Execute(object parameter)
|
|
|
+ public void Execute(object parameter)
|
|
|
{
|
|
|
if (UseProvidedParameter)
|
|
|
{
|
|
@@ -108,13 +75,6 @@ internal class Command : MarkupExtension
|
|
|
{
|
|
|
Command.Execute();
|
|
|
}
|
|
|
-
|
|
|
- return Unit.Default;
|
|
|
- }
|
|
|
-
|
|
|
- public void Dispose()
|
|
|
- {
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|