/// <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)); } }
/// <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 bool HandleGesture(IView view, OxyInputGesture gesture, OxyInputEventArgs args) { var command = this.GetCommand(gesture); return this.HandleCommand(command, view, args); }
/// <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); } }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var tg = other as OxyTouchGesture; return(tg != null); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var mwg = other as OxyMouseWheelGesture; return(mwg != null && mwg.Modifiers == this.Modifiers); }
/// <summary> /// Initializes a new instance of the <see cref="InputCommandBinding" /> class by a gesture. /// </summary> /// <param name="gesture">The gesture.</param> /// <param name="command">The command.</param> public InputCommandBinding(OxyInputGesture gesture, IViewCommand command) { this.Gesture = gesture; this.Command = command; }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var kg = other as OxyKeyGesture; return(kg != null && kg.Modifiers == this.Modifiers && kg.Key == this.Key); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var mg = other as OxyMouseDownGesture; return(mg != null && mg.Modifiers == this.Modifiers && mg.MouseButton == this.MouseButton && mg.ClickCount == this.ClickCount); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var mg = other as OxyMouseEnterGesture; return(mg != null && mg.Modifiers == this.Modifiers); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var sg = other as OxyShakeGesture; return sg != null; }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var mg = other as OxyMouseDownGesture; return mg != null && mg.Modifiers == this.Modifiers && mg.MouseButton == this.MouseButton && mg.ClickCount == this.ClickCount; }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var mg = other as OxyMouseEnterGesture; return mg != null && mg.Modifiers == this.Modifiers; }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var tg = other as OxyTouchGesture; return tg != null; }
/// <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; }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var mwg = other as OxyMouseWheelGesture; return mwg != null && mwg.Modifiers == this.Modifiers; }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var sg = other as OxyShakeGesture; return(sg != null); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns> public override bool Equals(OxyInputGesture other) { var kg = other as OxyKeyGesture; return kg != null && kg.Modifiers == this.Modifiers && kg.Key == this.Key; }