mirror of
https://github.com/MilkBarModding/MilkBarLauncher.git
synced 2025-06-17 04:31:00 +00:00
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Breath_of_the_Wild_Multiplayer.MVVM.Model;
|
|
using System;
|
|
using System.Windows.Input;
|
|
|
|
namespace Breath_of_the_Wild_Multiplayer.Source_files
|
|
{
|
|
public class RelayCommand : ICommand
|
|
{
|
|
private Action<object> _execute;
|
|
private Func<object, bool> _canExecute;
|
|
|
|
public event EventHandler CanExecuteChanged
|
|
{
|
|
add { CommandManager.RequerySuggested += value; }
|
|
remove { CommandManager.RequerySuggested -= value;}
|
|
}
|
|
|
|
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
|
|
{
|
|
_execute = execute;
|
|
_canExecute = canExecute;
|
|
}
|
|
|
|
public bool CanExecute(object parameter)
|
|
{
|
|
return _canExecute == null || _canExecute(parameter);
|
|
}
|
|
|
|
public void Execute(object parameter)
|
|
{
|
|
try
|
|
{
|
|
_execute(parameter);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
SharedData.LoadErrorMessage(ex.Message);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|