public override bool ProcessKeyEvent(IDiagramPresenter diagramPresenter, KeyEventArgsDg e)
		{
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			// if the keyPress was not handled by the base class, try to handle it here
			bool result = false;
			switch (e.EventType) {
				case KeyEventType.PreviewKeyDown:
				case KeyEventType.KeyPress:
					// do nothing
					break;
				case KeyEventType.KeyDown:
				case KeyEventType.KeyUp:
					if ((KeysDg) e.KeyCode == KeysDg.Delete) {
						// Update selected shape unter the mouse cursor because it was propably deleted
						if (!selectedShapeAtCursorInfo.IsEmpty &&
						    !diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape)) {
							SetSelectedShapeAtCursor(diagramPresenter, CurrentMouseState.X, CurrentMouseState.Y,
							                         diagramPresenter.ZoomedGripSize, ControlPointCapabilities.All);
							Invalidate(diagramPresenter);
						}
					}

					// Update Cursor when modifier keys are pressed or released
					if (((KeysDg) e.KeyCode & KeysDg.Shift) == KeysDg.Shift
					    || ((KeysDg) e.KeyCode & KeysDg.ShiftKey) == KeysDg.ShiftKey
					    || ((KeysDg) e.KeyCode & KeysDg.Control) == KeysDg.Control
					    || ((KeysDg) e.KeyCode & KeysDg.ControlKey) == KeysDg.ControlKey
					    || ((KeysDg) e.KeyCode & KeysDg.Alt) == KeysDg.Alt) {
						MouseState mouseState = CurrentMouseState;
						mouseState.Modifiers = (KeysDg) e.Modifiers;
						int cursorId = DetermineCursor(diagramPresenter, mouseState);
						diagramPresenter.SetCursor(cursorId);
					}
					break;
				default:
					throw new NShapeUnsupportedValueException(e.EventType);
			}
			if (base.ProcessKeyEvent(diagramPresenter, e)) result = true;
			return result;
		}
Exemple #2
0
		/// <summary>
		/// Processes a keyboard event.
		/// </summary>
		/// <param name="diagramPresenter">Diagram presenter where the event occurred.</param>
		/// <param name="e">Description of the keyboard event.</param>
		/// <returns>True if the event was handled, false if the event was not handled.</returns>
		public virtual bool ProcessKeyEvent(IDiagramPresenter diagramPresenter, KeyEventArgsDg e) {
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			bool result = false;
			switch (e.EventType) {
				case KeyEventType.KeyDown:
					// Cancel tool
					if (e.KeyCode == (int)KeysDg.Escape) {
						Cancel();
						result = true;
					}
					break;

				case KeyEventType.KeyPress:
				case KeyEventType.PreviewKeyDown:
				case KeyEventType.KeyUp:
					// do nothing
					break;
				default: throw new NShapeUnsupportedValueException(e.EventType);
			}
			diagramPresenter.Update();
			return result;
		}
Exemple #3
0
		/// <override></override>
		public override bool ProcessKeyEvent(IDiagramPresenter diagramPresenter, KeyEventArgsDg e) {
			return base.ProcessKeyEvent(diagramPresenter, e);
		}
 /// <override></override>
 public override bool ProcessKeyEvent(IDiagramPresenter diagramPresenter, KeyEventArgsDg e)
 {
     // nothing to do
     return false;
 }