Beispiel #1
0
 /// <summary>
 /// Unbinds the specified gesture.
 /// </summary>
 /// <param name="gesture">The gesture to unbind.</param>
 public virtual void Unbind(OxyInputGesture gesture)
 {
     // ReSharper disable once RedundantNameQualifier
     foreach (var icb in this.InputCommandBindings.Where(icb => icb.Gesture.Equals(gesture)).ToArray())
     {
         this.InputCommandBindings.Remove(icb);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Gets the command for the specified <see cref="OxyInputGesture" />.
        /// </summary>
        /// <param name="gesture">The input gesture.</param>
        /// <returns>A command.</returns>
        protected virtual IViewCommand GetCommand(OxyInputGesture gesture)
        {
            var binding = this.InputCommandBindings.FirstOrDefault(b => b.Gesture.Equals(gesture));

            if (binding == null)
            {
                return(null);
            }

            return(binding.Command);
        }
Beispiel #3
0
        /// <summary>
        /// Binds the specified command to the specified gesture. Removes old bindings to the gesture.
        /// </summary>
        /// <param name="gesture">The gesture.</param>
        /// <param name="command">The command. If <c>null</c>, the binding will be removed.</param>
        /// <remarks>This method was created to avoid calling a virtual method in the constructor.</remarks>
        protected void BindCore(OxyInputGesture gesture, IViewCommand command)
        {
            var current = this.InputCommandBindings.FirstOrDefault(icb => icb.Gesture.Equals(gesture));

            if (current != null)
            {
                this.InputCommandBindings.Remove(current);
            }

            if (command != null)
            {
                this.InputCommandBindings.Add(new InputCommandBinding(gesture, command));
            }
        }
Beispiel #4
0
        /// <summary>
        /// Handles the specified gesture.
        /// </summary>
        /// <param name="view">The plot view.</param>
        /// <param name="gesture">The gesture.</param>
        /// <param name="args">The <see cref="OxyInputEventArgs" /> instance containing the event data.</param>
        /// <returns><c>true</c> if the event was handled.</returns>
        public virtual bool HandleGesture(IView view, OxyInputGesture gesture, OxyInputEventArgs args)
        {
            var command = this.GetCommand(gesture);

            return(this.HandleCommand(command, view, args));
        }