Exemple #1
0
		/// <override></override>
		public override bool ProcessMouseEvent(IDiagramPresenter diagramPresenter, MouseEventArgsDg e) {
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			bool result = false;

			MouseState newMouseState = MouseState.Empty;
			newMouseState.Buttons = e.Buttons;
			newMouseState.Modifiers = e.Modifiers;
			diagramPresenter.ControlToDiagram(e.Position, out newMouseState.Position);

			diagramPresenter.SuspendUpdate();
			try {
				switch (e.EventType) {
					case MouseEventType.MouseDown:
						timer.Stop();
						break;

					case MouseEventType.MouseMove:
						if (CurrentMouseState.Position != newMouseState.Position) {
							if (newMouseState.IsButtonDown(MouseButtonsDg.Left)
								&& diagramPresenter.Project.SecurityManager.IsGranted(Permission.Insert)) {
								diagramPresenter.ControlToDiagram(e.Position, out p);
								currentStroke.Add(p.X, p.Y);
							}
							diagramPresenter.SetCursor(penCursorId);
						}
						Invalidate(diagramPresenter);
						break;

					case MouseEventType.MouseUp:
						if (newMouseState.IsButtonDown(MouseButtonsDg.Left)
							&& diagramPresenter.Project.SecurityManager.IsGranted(Permission.Insert)) {
							StartToolAction(diagramPresenter, 0, newMouseState, false);

							strokeSet.Add(currentStroke);
							currentStroke = new Stroke();
							timer.Start();
						}
						break;

					default: throw new NShapeUnsupportedValueException(e.EventType);
				}
			} finally { diagramPresenter.ResumeUpdate(); }
			base.ProcessMouseEvent(diagramPresenter, e);
			return result;
		}
		public override bool ProcessMouseEvent(IDiagramPresenter diagramPresenter, MouseEventArgsDg e)
		{
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			bool result = false;
			// get new mouse state
			MouseState newMouseState = MouseState.Empty;
			newMouseState.Buttons = e.Buttons;
			newMouseState.Modifiers = e.Modifiers;
			diagramPresenter.ControlToDiagram(e.Position, out newMouseState.Position);

			diagramPresenter.SuspendUpdate();
			try {
				// Only process mouse action if the position of the mouse or a mouse button state changed
				//if (e.EventType != MouseEventType.MouseMove || newMouseState.Position != CurrentMouseState.Position) {
				// Process the mouse event
				switch (e.EventType) {
					case MouseEventType.MouseDown:
						// Start drag action such as drawing a SelectionFrame or moving selectedShapes/shape handles
						result = ProcessMouseDown(diagramPresenter, newMouseState);
						break;

					case MouseEventType.MouseMove:
						// Set cursors depending on HotSpots or draw moving/resizing preview
						result = ProcessMouseMove(diagramPresenter, newMouseState);
						break;

					case MouseEventType.MouseUp:
						// perform selection/moving/resizing
						result = ProcessMouseUp(diagramPresenter, newMouseState);
						break;

					default:
						throw new NShapeUnsupportedValueException(e.EventType);
				}
				//}
			}
			finally {
				diagramPresenter.ResumeUpdate();
			}
			base.ProcessMouseEvent(diagramPresenter, e);
			return result;
		}
Exemple #3
0
 /// <ToBeCompleted></ToBeCompleted>
 public LayerMouseEventArgs(Layer layer, LayerItem item, MouseEventArgsDg mouseEventArgs)
     : this(layer, item, mouseEventArgs.EventType, mouseEventArgs.Buttons, mouseEventArgs.Clicks, mouseEventArgs.WheelDelta, mouseEventArgs.Position, mouseEventArgs.Modifiers)
 {
     if (layer == null) throw new ArgumentNullException("layer");
     this.layer = layer;
     this.item = item;
 }
Exemple #4
0
			protected internal void SetMouseEvent(Layer layer, LayerItem item, MouseEventType eventType, MouseEventArgsDg eventArgs) {
				this.SetMouseEvent(eventType, eventArgs.Buttons, eventArgs.Clicks, eventArgs.WheelDelta, eventArgs.Position, eventArgs.Modifiers);
				this.Item = item;
				this.Layer = layer;
			}
 /// <summary>
 /// Initializing a new instance of <see cref="T:Dataweb.NShape.Controllers.DiagramPresenterShapeClickEventArgs" />
 /// </summary>
 public DiagramPresenterShapeClickEventArgs(Shape shape, MouseEventArgsDg mouseEventArgs)
     : this()
 {
     this.shape = shape;
     this.mouseEventArgs = mouseEventArgs;
 }
Exemple #6
0
		/// <override></override>
		public override bool ProcessMouseEvent(IDiagramPresenter diagramPresenter, MouseEventArgsDg e) {
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			bool result = false;
			
			MouseState newMouseState = MouseState.Empty;
			newMouseState.Buttons = e.Buttons;
			newMouseState.Modifiers = e.Modifiers;

			// Return if action is not allowed
			if (!diagramPresenter.Project.SecurityManager.IsGranted(Permission.Insert, Template.Shape))
				return result;

			diagramPresenter.ControlToDiagram(e.Position, out newMouseState.Position);

			diagramPresenter.SuspendUpdate();
			try {
				switch (e.EventType) {
					case MouseEventType.MouseMove:
						if (newMouseState.Position != CurrentMouseState.Position) {
							// If no Preview exists, create a new one by starting a new ToolAction
							if (!IsToolActionPending)
								StartToolAction(diagramPresenter, (int)Action.Create, newMouseState, false);

							Invalidate(ActionDiagramPresenter);
							// Move preview shape to Mouse Position
							PreviewShape.MoveTo(newMouseState.X, newMouseState.Y);
							// Snap to grid
							if (diagramPresenter.SnapToGrid) {
								int snapDeltaX = 0, snapDeltaY = 0;
								FindNearestSnapPoint(diagramPresenter, PreviewShape, 0, 0, out snapDeltaX, out snapDeltaY);
								PreviewShape.MoveTo(newMouseState.X + snapDeltaX, newMouseState.Y + snapDeltaY);
							}
							Invalidate(ActionDiagramPresenter);
							result = true;
						}
						break;

					case MouseEventType.MouseUp:
						if (IsToolActionPending && newMouseState.IsButtonDown(MouseButtonsDg.Left)) {
							try {
								// Left mouse button was pressed: Create shape
								executing = true;
								Invalidate(ActionDiagramPresenter);
								if (ActionDiagramPresenter.Diagram != null) {
									int x = PreviewShape.X;
									int y = PreviewShape.Y;

									Shape newShape = Template.CreateShape();
									newShape.ZOrder = ActionDiagramPresenter.Project.Repository.ObtainNewTopZOrder(ActionDiagramPresenter.Diagram);
									newShape.MoveTo(x, y);

									ActionDiagramPresenter.InsertShape(newShape);
									result = true;
								}
							} finally {
								executing = false;
							}
							EndToolAction();
							OnToolExecuted(ExecutedEventArgs);
						} else if (newMouseState.IsButtonDown(MouseButtonsDg.Right)) {
							// Right mouse button was pressed: Cancel Tool
							Cancel();
							result = true;
						}
						break;

					case MouseEventType.MouseDown:
						// nothing to to yet
						// ToDo 3: Implement dragging a frame with the mouse and fit the shape into that frame when releasing the button
						break;

					default: throw new NShapeUnsupportedValueException(e.EventType);
				}
			} finally { diagramPresenter.ResumeUpdate(); }
			base.ProcessMouseEvent(diagramPresenter, e);
			return result;
		}
Exemple #7
0
		/// <override></override>
		public override bool ProcessMouseEvent(IDiagramPresenter diagramPresenter, MouseEventArgsDg e) {
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			bool result = false;

			MouseState newMouseState = MouseState.Empty;
			newMouseState.Buttons = e.Buttons;
			newMouseState.Modifiers = e.Modifiers;
			diagramPresenter.ControlToDiagram(e.Position, out newMouseState.Position);

			diagramPresenter.SuspendUpdate();
			try {
				switch (e.EventType) {
					case MouseEventType.MouseMove:
						if (CurrentMouseState.Position != newMouseState.Position)
							ProcessMouseMove(diagramPresenter, newMouseState);
						break;
					case MouseEventType.MouseDown:
						// MouseDown starts drag-based actions
						// ToDo: Implement these features: Adding Segments to existing Lines, Move existing Lines and their ControlPoints
						if (e.Clicks > 1) result = ProcessDoubleClick(diagramPresenter, newMouseState);
						else result = ProcessMouseClick(diagramPresenter, newMouseState);
						break;

					case MouseEventType.MouseUp:
						// MouseUp finishes drag-actions. Click-based actions are handled by the MouseClick event
						// ToDo: Implement these features: Adding Segments to existing Lines, Move existing Lines and their ControlPoints
						break;

					default: throw new NShapeUnsupportedValueException(e.EventType);
				}
			} finally { diagramPresenter.ResumeUpdate(); }
			base.ProcessMouseEvent(diagramPresenter, e);
			return result;
		}
Exemple #8
0
		/// <summary>
		/// Processes a mouse event.
		/// </summary>
		/// <param name="diagramPresenter">Diagram presenter where the event occurred.</param>
		/// <param name="e">Description of the mouse event.</param>
		/// <remarks>When overriding, the base classes method has to be called at the end.</remarks>
		/// <returns>True if the event was handled, false if the event was not handled.</returns>
		public virtual bool ProcessMouseEvent(IDiagramPresenter diagramPresenter, MouseEventArgsDg e) {
			if (diagramPresenter == null) throw new ArgumentNullException("display");
			currentMouseState.Buttons = e.Buttons;
			currentMouseState.Modifiers = e.Modifiers;
			diagramPresenter.ControlToDiagram(e.Position, out currentMouseState.Position);
			diagramPresenter.Update();
			return false;
		}