Ejemplo n.º 1
0
        public bool Change <T>(ICommandToken <T> token, ICommandTrigger <T> trigger)
        {
            var command = _commands[token].Command as ICommand <T>;

            Remove(token);
            Add(trigger, command, token);
            return(true);
        }
Ejemplo n.º 2
0
 private ICommandToken <TArgs> Add <TArgs>(ICommandTrigger <TArgs> trigger, ICommand <TArgs> command, ICommandToken <TArgs> token = null)
 {
     trigger.CanExecute += command.CanExecute;
     trigger.Execute    += command.Execute;
     trigger.OnAdd(command);
     token ??= new CommandToken <TArgs>(this);
     _commands.Add(token, new Entry(trigger, command));
     return(token);
 }
Ejemplo n.º 3
0
        public ICommandToken <TArgs> Add <TArgs>(ICommandTrigger <TArgs> trigger, Action <TArgs> execute,
                                                 Predicate <TArgs> canExecute = null, string description = "")
        {
            var command = new Command <TArgs>()
            {
                Execute = execute, CanExecute = canExecute, Description = description
            };

            return(Add(trigger, command));
        }
Ejemplo n.º 4
0
        private static void TriggerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FrameworkElement element = d as FrameworkElement;

            ICommandTrigger commandTrigger = e.NewValue as ICommandTrigger;

            if (commandTrigger != null)
            {
                commandTrigger.Initialize(element);
            }
        }
Ejemplo n.º 5
0
        private ICommandTrigger DestroyTrigger(object key)
        {
            if (!_triggers.ContainsKey(key))
            {
                return(null);
            }
            ICommandTrigger trigger = _triggers [key];

            trigger.Deactivate();
            _triggers.Remove(key);
            return(trigger);
        }
Ejemplo n.º 6
0
 public static void SetTrigger(FrameworkElement source, ICommandTrigger value)
 {
     source.SetValue(TriggerProperty, value);
 }
Ejemplo n.º 7
0
		public static void SetTrigger(FrameworkElement source, ICommandTrigger value)
		{
			source.SetValue(TriggerProperty, value);
		}
Ejemplo n.º 8
0
 /// <summary>
 /// Set <see cref="ICommandBinding"/> <see cref="ICommandBinding.Trigger"/> and command
 /// parameter (see <see cref="ICommand.Execute"/>)
 /// </summary>
 /// <param name="source">Event source</param>
 /// <param name="parameter">Optional command parameter (see <see cref="ICommand.Execute"/>)</param>
 public void To(ICommandTrigger source, object parameter = null)
 {
     Binding.Trigger   = source;
     Binding.Parameter = parameter;
 }
 private void InitializeCommandSource(FrameworkElement source, ICommandTrigger child)
 {
     child.Initialize(source);
     _initList.Add(child);
 }
Ejemplo n.º 10
0
        /*============================================================================*/
        /* Constructor                                                                */
        /*============================================================================*/

        /// <summary>
        /// Create a command mapping list
        /// </summary>
        /// <param name="trigger">The trigger that owns this list</param>
        /// <param name="processors">A reference to the mapping processors for this command map</param>
        /// <param name="logger">Optional logger</param>
        public CommandMappingList(ICommandTrigger trigger, IEnumerable <Processor> processors, ILogging logger = null)
        {
            _trigger    = trigger;
            _processors = processors;
            _logger     = logger;
        }
		/*============================================================================*/
		/* Constructor                                                                */
		/*============================================================================*/

		/// <summary>
		/// Create a command mapping list
		/// </summary>
		/// <param name="trigger">The trigger that owns this list</param>
		/// <param name="processors">A reference to the mapping processors for this command map</param>
		/// <param name="logger">Optional logger</param>
		public CommandMappingList (ICommandTrigger trigger, IEnumerable<Processor> processors, ILogger logger = null)
		{
			_trigger = trigger;
			_processors =  processors;
			_logger = logger;
		}