GameEngine游戏引擎前端界面wpf页面实现

1.RelayCommon.cs

using System.Windows.Input;

namespace PrimalEditor.Common
{


    public class RelayCommand : ICommand
    {

        private readonly Action _execute;
        private readonly Predicate _canExecute;

        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }

        }

        public bool CanExecute(object parameter)
        {

            return _canExecute?.Invoke((T)parameter) ?? true;


        }
        public void Execute(object parameter)
        {

            _execute((T)parameter);

        }

        public RelayCommand(Action execute, Predicate canExecute = null)
        {


            _execute = execute ?? throw new ArgumentNullException(nameof(execute));
            _canExecute = canExecute;

        }


    }

}
 

你可能感兴趣的:(游戏引擎,前端,wpf)