• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IDiagramPresenter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDiagramPresenter的典型用法代码示例。如果您正苦于以下问题:C# IDiagramPresenter类的具体用法?C# IDiagramPresenter怎么用?C# IDiagramPresenter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDiagramPresenter类属于命名空间,在下文中一共展示了IDiagramPresenter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ExportDiagramDialog

		/// <summary>
		/// Initializes a new Instance of <see cref="T:Dataweb.NShape.WinFormsUI.ExportDiagramDialog" />.
		/// </summary>
		public ExportDiagramDialog(IDiagramPresenter diagramPresenter) {
			InitializeComponent();
			Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);

			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			this.diagramPresenter = diagramPresenter;
			InitializeDialog();
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:11,代码来源:ExportDiagramDialog.cs


示例2: InPlaceTextBox

		/// <summary>
		/// Creates a new instance of Dataweb.NShape.WinFormsUI.InPlaceTextBox.
		/// </summary>
		public InPlaceTextBox(IDiagramPresenter owner, ICaptionedShape shape, int captionIndex, string currentText, string newText) {
			Construct(owner, shape, captionIndex, currentText, newText);
			// Set Text
			originalText = currentText;
			if (string.IsNullOrEmpty(newText)) {
				// Preselect the whole text if the user has not started typing yet
				base.Text = currentText;
				SelectAll();
			} else {
				// Set the types text and place the cursor at the end of the text
				base.Text = newText;
				SelectionStart = Text.Length;
			}
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:17,代码来源:InplaceTextBox.cs


示例3: ProcessMouseEvent

		/// <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;
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:46,代码来源:FreeHandTool.cs


示例4: ProcessMouseEvent

		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;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:42,代码来源:ConfigFiltersAndPatching-Tools.cs


示例5: ProcessKeyEvent

		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;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:40,代码来源:ConfigFiltersAndPatching-Tools.cs


示例6: FinishConnection

		private bool FinishConnection(IDiagramPresenter diagramPresenter)
		{
			bool result = false;
			if (currentConnectionLine.DestinationDataComponent != null &&
			    currentConnectionLine.SourceDataFlowComponentReference != null) {
				// check to see if what we're connecting it to is already connected to something (else): if so, remove that line.
				// (we don't need to remove the dataflow component as source; since a component can only have a single source, it
				// will be updated/overwritten by the 'SetComponentSource' below.)
				FilterSetupShapeBase otherShape =
					currentConnectionLine.GetConnectionInfo(ControlPointId.LastVertex, null).OtherShape as FilterSetupShapeBase;
				ControlPointId pointId = currentConnectionLine.GetConnectionInfo(ControlPointId.LastVertex, null).OtherPointId;
				if (otherShape != null) {
					foreach (ShapeConnectionInfo ci in otherShape.GetConnectionInfos(pointId, null)) {
						if (ci.OtherShape == currentConnectionLine)
							continue;
						diagramPresenter.DeleteShape(ci.OtherShape, false);
					}
				}

				currentConnectionLine.SecurityDomainName =
					ConfigFiltersAndPatching.SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS_DELETABLE;

				VixenSystem.DataFlow.SetComponentSource(currentConnectionLine.DestinationDataComponent,
				                                        currentConnectionLine.SourceDataFlowComponentReference);

				OnDataFlowModificationMade();

				result = true;
			}
			else {
				currentConnectionLine.Disconnect(ControlPointId.FirstVertex);
				currentConnectionLine.Disconnect(ControlPointId.LastVertex);
				diagramPresenter.DeleteShape(currentConnectionLine, false);
			}

			return result;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:37,代码来源:ConfigFiltersAndPatching-Tools.cs


示例7: Invalidate

		public override void Invalidate(IDiagramPresenter diagramPresenter)
		{
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			switch (CurrentAction) {
				case Action.None:
				case Action.Select:
					if (!selectedShapeAtCursorInfo.IsEmpty) {
						selectedShapeAtCursorInfo.Shape.Invalidate();
						diagramPresenter.InvalidateGrips(selectedShapeAtCursorInfo.Shape, ControlPointCapabilities.All);
					}
					break;

				case Action.SelectWithFrame:
					diagramPresenter.DisplayService.Invalidate(frameRect);
					break;

				case Action.MoveHandle:
				case Action.MoveShape:
					if (Previews.Count > 0) {
						InvalidateShapes(diagramPresenter, Previews.Values, false);
						if (diagramPresenter.SnapToGrid) {
							Shape previewAtCursor = FindPreviewOfShape(selectedShapeAtCursorInfo.Shape);
							diagramPresenter.InvalidateSnapIndicators(previewAtCursor);
						}
						if (CurrentAction == Action.MoveHandle && selectedShapeAtCursorInfo.IsCursorAtGluePoint)
							InvalidateConnectionTargets(diagramPresenter, CurrentMouseState.X, CurrentMouseState.Y);
					}
					break;

				case Action.ConnectShapes:
					if (currentConnectionLine != null)
						currentConnectionLine.Invalidate();
					break;

				default:
					throw new NShapeUnsupportedValueException(typeof (MenuItemDef), CurrentAction);
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:38,代码来源:ConfigFiltersAndPatching-Tools.cs


示例8: IsMoveHandleFeasible

		private bool IsMoveHandleFeasible(IDiagramPresenter diagramPresenter, MouseState mouseState,
		                                  ShapeAtCursorInfo shapeAtCursorInfo)
		{
			if (shapeAtCursorInfo.IsEmpty)
				return false;
			// Collides with the resize modifiers
			//if (mouseState.IsKeyPressed(KeysDg.Shift)) return false;
			if (shapeAtCursorInfo.Shape.HasControlPointCapability(shapeAtCursorInfo.ControlPointId, ControlPointCapabilities.Glue)) {
				if (!diagramPresenter.Project.SecurityManager.IsGranted(Permission.Connect, diagramPresenter.SelectedShapes))
					return false;
			}
			else {
				if (!diagramPresenter.Project.SecurityManager.IsGranted(Permission.Layout, diagramPresenter.SelectedShapes))
					return false;
			}
			if (
				!shapeAtCursorInfo.Shape.HasControlPointCapability(shapeAtCursorInfo.ControlPointId,
				                                                   ControlPointCapabilities.Resize | ControlPointCapabilities.Glue
				 	/*| ControlPointCapabilities.Movable*/))
				return false;
			if (diagramPresenter.SelectedShapes.Count > 1) {
				// GluePoints may only be moved alone
				if (shapeAtCursorInfo.Shape.HasControlPointCapability(shapeAtCursorInfo.ControlPointId,
				                                                      ControlPointCapabilities.Glue))
					return false;
				// Check if all shapes that are going to be resizes are of the same type
				Shape lastShape = null;
				foreach (Shape shape in diagramPresenter.SelectedShapes) {
					if (lastShape != null && lastShape.Type != shape.Type)
						return false;
					lastShape = shape;
				}
			}
			return true;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:35,代码来源:ConfigFiltersAndPatching-Tools.cs


示例9: Invalidate

 public override void Invalidate(IDiagramPresenter diagramPresenter)
 {
     // Nothing to do
 }
开发者ID:kjburns31,项目名称:vixen-modules,代码行数:4,代码来源:ShapeInfoDialog.cs


示例10: Draw

 public override void Draw(IDiagramPresenter diagramPresenter)
 {
     Shape shape = null;
     if (diagramPresenter.Diagram != null && diagramPresenter.Diagram.Shapes.Count > 0)
         shape = diagramPresenter.Diagram.Shapes.TopMost;
     if (shape != null) {
         diagramPresenter.ResetTransformation();
         try {
             foreach (ControlPointId id in shape.GetControlPointIds(ControlPointCapabilities.All)) {
                 if (id == ControlPointId.Reference) continue;
                 IndicatorDrawMode drawMode = (SelectedPointId == id) ? IndicatorDrawMode.Highlighted : IndicatorDrawMode.Normal;
                 if (shape.HasControlPointCapability(id, ControlPointCapabilities.Resize))
                     diagramPresenter.DrawResizeGrip(drawMode, shape, id);
                 if (shape.HasControlPointCapability(id, ControlPointCapabilities.Connect | ControlPointCapabilities.Glue))
                     diagramPresenter.DrawConnectionPoint(drawMode, shape, id);
                 if (shape.HasControlPointCapability(id, ControlPointCapabilities.Rotate))
                     diagramPresenter.DrawRotateGrip(drawMode, shape, id);
             }
         } finally {
             diagramPresenter.RestoreTransformation();
         }
     }
 }
开发者ID:kjburns31,项目名称:vixen-modules,代码行数:23,代码来源:ShapeInfoDialog.cs


示例11: PrepareMoveHandlePreview

		// prepare drawing preview of resize action 
		private void PrepareMoveHandlePreview(IDiagramPresenter diagramPresenter, MouseState mouseState)
		{
			InvalidateConnectionTargets(diagramPresenter, CurrentMouseState.X, CurrentMouseState.Y);

			int distanceX = mouseState.X - ActionStartMouseState.X;
			int distanceY = mouseState.Y - ActionStartMouseState.Y;

			// calculate "Snap to Grid/ControlPoint" offset
			snapDeltaX = snapDeltaY = 0;
			if (selectedShapeAtCursorInfo.IsCursorAtGluePoint) {
				ControlPointId targetPtId;
				Shape targetShape = FindNearestControlPoint(diagramPresenter, selectedShapeAtCursorInfo.Shape,
				                                            selectedShapeAtCursorInfo.ControlPointId,
				                                            ControlPointCapabilities.Connect, distanceX, distanceY, out snapDeltaX,
				                                            out snapDeltaY, out targetPtId);
			}
			else
				FindNearestSnapPoint(diagramPresenter, selectedShapeAtCursorInfo.Shape, selectedShapeAtCursorInfo.ControlPointId,
				                     distanceX, distanceY, out snapDeltaX, out snapDeltaY);
			distanceX += snapDeltaX;
			distanceY += snapDeltaY;

			// Reset all preview shapes to start values
			ResetPreviewShapes(diagramPresenter);

			// Move selected shapes
			ResizeModifiers resizeModifier = GetResizeModifier(mouseState);
			Point originalPtPos = Point.Empty;
			foreach (Shape selectedShape in diagramPresenter.SelectedShapes) {
				Shape previewShape = FindPreviewOfShape(selectedShape);
				// Perform movement
				if (previewShape.HasControlPointCapability(selectedShapeAtCursorInfo.ControlPointId, ControlPointCapabilities.Resize))
					previewShape.MoveControlPointBy(selectedShapeAtCursorInfo.ControlPointId, distanceX, distanceY, resizeModifier);
			}

			InvalidateConnectionTargets(diagramPresenter, mouseState.X, mouseState.Y);
		}
开发者ID:stewmc,项目名称:vixen,代码行数:38,代码来源:ConfigFiltersAndPatching-Tools.cs


示例12: DetermineMouseDownAction

		/// <summary>
		/// Decide which tool action is suitable for the current mouse state.
		/// </summary>
		private Action DetermineMouseDownAction(IDiagramPresenter diagramPresenter, MouseState mouseState)
		{
			if (mouseState.IsButtonDown(MouseButtonsDg.Left) || mouseState.IsButtonDown(MouseButtonsDg.Right)) {
				// if left or right buttons are down, start a 'select' action. This will refine to an
				// appropriate drag action later on (when mouse moving) based on the mouse button, otherwise
				// it will (de)select the shape on mouseup
				return Action.Select;
			}
			// Ignore other pressed mouse buttons
			return CurrentAction;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:14,代码来源:ConfigFiltersAndPatching-Tools.cs


示例13: ProcessMouseUp

		private bool ProcessMouseUp(IDiagramPresenter diagramPresenter, MouseState mouseState)
		{
			bool result = false;

			if (!selectedShapeAtCursorInfo.IsEmpty &&
			    !diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape))
				selectedShapeAtCursorInfo.Clear();

			switch (CurrentAction) {
				case Action.None:
					// do nothing
					break;

				case Action.Select:
					// Perform selection, but only if it was with the left mouse button. If it was right mouse, ignore it. (Select is only
					// initiated on right mouse earlier (in ProcessMouseDown) to allow it to 'refine' into other drag actions. If it's
					// still a select by MouseUp, then we can ignore it.)
					if (!mouseState.IsButtonDown(MouseButtonsDg.Right)) {
						ShapeAtCursorInfo shapeAtCursorInfo = FindShapeAtCursor(diagramPresenter, mouseState.X, mouseState.Y,
						                                                        ControlPointCapabilities.None, 0, false);
						result = PerformSelection(ActionDiagramPresenter, mouseState, shapeAtCursorInfo);
						SetSelectedShapeAtCursor(ActionDiagramPresenter, mouseState.X, mouseState.Y, ActionDiagramPresenter.ZoomedGripSize,
						                         ControlPointCapabilities.All);
					}
					EndToolAction();
					break;

				case Action.SelectWithFrame:
					// select all selectedShapes within the frame
					result = PerformFrameSelection(ActionDiagramPresenter, mouseState);
					while (IsToolActionPending)
						EndToolAction();
					break;

				case Action.MoveHandle:
					result = PerformMoveHandle(ActionDiagramPresenter);
					while (IsToolActionPending)
						EndToolAction();
					break;

				case Action.MoveShape:
					result = PerformMoveShape(ActionDiagramPresenter);
					while (IsToolActionPending)
						EndToolAction();
					break;

				case Action.ConnectShapes:
					result = FinishConnection(ActionDiagramPresenter);
					while (IsToolActionPending)
						EndToolAction();
					break;

				default:
					throw new NShapeUnsupportedValueException(CurrentAction);
			}

			SetSelectedShapeAtCursor(diagramPresenter, mouseState.X, mouseState.Y, diagramPresenter.ZoomedGripSize,
			                         ControlPointCapabilities.All);
			diagramPresenter.SetCursor(DetermineCursor(diagramPresenter, mouseState));

			OnToolExecuted(ExecutedEventArgs);
			return result;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:63,代码来源:ConfigFiltersAndPatching-Tools.cs


示例14: ProcessMouseMove

		private bool ProcessMouseMove(IDiagramPresenter diagramPresenter, MouseState mouseState)
		{
			bool result = true;

			if (!selectedShapeAtCursorInfo.IsEmpty &&
			    !diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape))
				selectedShapeAtCursorInfo.Clear();

			switch (CurrentAction) {
				case Action.None:
					result = false;
					SetSelectedShapeAtCursor(diagramPresenter, mouseState.X, mouseState.Y, diagramPresenter.ZoomedGripSize,
					                         ControlPointCapabilities.All);
					Invalidate(diagramPresenter);
					break;

				case Action.Select:

					ShapeAtCursorInfo shapeAtActionStartInfo =
						FindShapeAtCursor(ActionDiagramPresenter, ActionStartMouseState.X, ActionStartMouseState.Y,
						                  ControlPointCapabilities.Connect, 3, false);

					Action newAction = DetermineMouseMoveAction(ActionDiagramPresenter, mouseState, shapeAtActionStartInfo);

					// If the action has changed, prepare and start the new action
					if (newAction != CurrentAction) {
						switch (newAction) {
								// Select --> SelectWithFrame
							case Action.SelectWithFrame:
								StartToolAction(diagramPresenter, (int) newAction, ActionStartMouseState, true);
								PrepareSelectionFrame(ActionDiagramPresenter, ActionStartMouseState);
								break;

								// Select --> (Select shape and) move shape
							case Action.MoveShape:
							case Action.MoveHandle:
								if (selectedShapeAtCursorInfo.IsEmpty) {
									// Select shape at cursor before start dragging it
									PerformSelection(ActionDiagramPresenter, ActionStartMouseState, shapeAtActionStartInfo);
									SetSelectedShapeAtCursor(diagramPresenter, ActionStartMouseState.X, ActionStartMouseState.Y, 0,
									                         ControlPointCapabilities.None);
								}
								// Init moving shape
								CreatePreviewShapes(ActionDiagramPresenter);
								StartToolAction(diagramPresenter, (int) newAction, ActionStartMouseState, true);
								PrepareMoveShapePreview(ActionDiagramPresenter, ActionStartMouseState);
								break;

							case Action.ConnectShapes:
								bool connectionStarted = PrepareConnection(diagramPresenter, mouseState, shapeAtActionStartInfo, newAction);
								if (connectionStarted)
									StartToolAction(diagramPresenter, (int) newAction, ActionStartMouseState, true);
								break;

							case Action.None:
							case Action.Select:
								throw new Exception("Unhandled state change in MouseMove");

							default:
								throw new Exception(string.Format("Unexpected {0} value: {1}", CurrentAction.GetType().Name, CurrentAction));
						}
					}
					Invalidate(ActionDiagramPresenter);
					break;

				case Action.SelectWithFrame:
					PrepareSelectionFrame(ActionDiagramPresenter, mouseState);
					break;

				case Action.MoveHandle:
					PrepareMoveHandlePreview(ActionDiagramPresenter, mouseState);
					break;

				case Action.MoveShape:
					PrepareMoveShapePreview(diagramPresenter, mouseState);
					break;

				case Action.ConnectShapes:
					FilterSetupShapeBase filterShape = null;
					foreach (
						var shape in
							FindShapesSortedByZOrder(ActionDiagramPresenter, mouseState.X, mouseState.Y, ControlPointCapabilities.None, 5)) {
						filterShape = shape as FilterSetupShapeBase;
						if (filterShape != null)
							break;
					}
					UpdateConnection(mouseState, filterShape);
					break;

				default:
					throw new NShapeUnsupportedValueException(typeof (Action), CurrentAction);
			}

			int cursorId = DetermineCursor(diagramPresenter, mouseState);
			if (CurrentAction == Action.None) diagramPresenter.SetCursor(cursorId);
			else ActionDiagramPresenter.SetCursor(cursorId);

			return result;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:99,代码来源:ConfigFiltersAndPatching-Tools.cs


示例15: ProcessMouseDown

		private bool ProcessMouseDown(IDiagramPresenter diagramPresenter, MouseState mouseState)
		{
			// Check if the selected shape at cursor is still valid
			if (!selectedShapeAtCursorInfo.IsEmpty
			    && (!diagramPresenter.SelectedShapes.Contains(selectedShapeAtCursorInfo.Shape)
			        ||
			        selectedShapeAtCursorInfo.Shape.HitTest(mouseState.X, mouseState.Y, ControlPointCapabilities.All,
			                                                diagramPresenter.ZoomedGripSize) == ControlPointId.None)) {
				selectedShapeAtCursorInfo.Clear();
			}

			// If no action is pending, try to start a new one...
			if (CurrentAction == Action.None) {
				// Get suitable action (depending on the currently selected shape under the mouse cursor)
				Action newAction = DetermineMouseDownAction(diagramPresenter, mouseState);
				if (newAction != Action.None) {
					StartToolAction(diagramPresenter, (int) newAction, mouseState, false);
					Invalidate(ActionDiagramPresenter);
				}
			}
			return false;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:22,代码来源:ConfigFiltersAndPatching-Tools.cs


示例16: StartToolAction

		protected override void StartToolAction(IDiagramPresenter diagramPresenter, int action, MouseState mouseState,
		                                        bool wantAutoScroll)
		{
			base.StartToolAction(diagramPresenter, action, mouseState, wantAutoScroll);
			// Empty selection frame
			frameRect.Location = mouseState.Position;
			frameRect.Size = Size.Empty;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:8,代码来源:ConfigFiltersAndPatching-Tools.cs


示例17: PrepareMoveShapePreview

		// prepare drawing preview of move action
		private void PrepareMoveShapePreview(IDiagramPresenter diagramPresenter, MouseState mouseState)
		{
			// calculate the movement
			int distanceX = mouseState.X - ActionStartMouseState.X;
			int distanceY = mouseState.Y - ActionStartMouseState.Y;
			// calculate "Snap to Grid" offset
			snapDeltaX = snapDeltaY = 0;
			if (diagramPresenter.SnapToGrid && !selectedShapeAtCursorInfo.IsEmpty) {
				FindNearestSnapPoint(diagramPresenter, selectedShapeAtCursorInfo.Shape, distanceX, distanceY, out snapDeltaX,
				                     out snapDeltaY);
				distanceX += snapDeltaX;
				distanceY += snapDeltaY;
			}

			// Reset all shapes to start values
			ResetPreviewShapes(diagramPresenter);

			// Move (preview copies of) the selected shapes
			Rectangle shapeBounds = Rectangle.Empty;
			foreach (Shape originalShape in diagramPresenter.SelectedShapes) {
				// Get preview of the shape to move...
				Shape previewShape = FindPreviewOfShape(originalShape);
				// ...and move the preview shape to the new position
				previewShape.MoveTo(originalShape.X + distanceX, originalShape.Y + distanceY);
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:27,代码来源:ConfigFiltersAndPatching-Tools.cs


示例18: PerformMoveShape

		// Apply the move action
		private bool PerformMoveShape(IDiagramPresenter diagramPresenter)
		{
			bool result = false;
			if (selectedShapeAtCursorInfo.IsEmpty) {
				// This should never happen...
				Debug.Assert(!selectedShapeAtCursorInfo.IsEmpty);
			}

			if (ActionStartMouseState.Position != CurrentMouseState.Position) {
				// calculate the movement
				int distanceX = CurrentMouseState.X - ActionStartMouseState.X;
				int distanceY = CurrentMouseState.Y - ActionStartMouseState.Y;
				//snapDeltaX = snapDeltaY = 0;
				//if (diagramPresenter.SnapToGrid)
				//   FindNearestSnapPoint(diagramPresenter, SelectedShapeAtCursorInfo.Shape, distanceX, distanceY, out snapDeltaX, out snapDeltaY, ControlPointCapabilities.All);

				ICommand cmd = new MoveShapeByCommand(diagramPresenter.SelectedShapes, distanceX + snapDeltaX,
				                                      distanceY + snapDeltaY);
				diagramPresenter.Project.ExecuteCommand(cmd);

				snapDeltaX = snapDeltaY = 0;
				snapPtId = ControlPointId.None;
				result = true;
			}
			return result;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:27,代码来源:ConfigFiltersAndPatching-Tools.cs


示例19: DetermineMouseMoveAction

		/// <summary>
		/// Decide which tool action is suitable for the current mouse state.
		/// </summary>
		private Action DetermineMouseMoveAction(IDiagramPresenter diagramPresenter, MouseState mouseState,
		                                        ShapeAtCursorInfo shapeAtCursorInfo)
		{
			switch (CurrentAction) {
				case Action.None:
				case Action.MoveHandle:
				case Action.MoveShape:
				case Action.SelectWithFrame:
				case Action.ConnectShapes:
					// Do not change the current action
					return CurrentAction;

				case Action.Select:
					if (mouseState.IsButtonDown(MouseButtonsDg.Left)) {
						// if we're doing something with the left mouse button, it will be a 'drag' style action
						if (!IsDragActionFeasible(mouseState)) {
							return CurrentAction;
						}

						// Check if cursor is over a control point and moving grips is feasible
						if (selectedShapeAtCursorInfo.IsCursorAtGrip) {
							if (IsMoveHandleFeasible(diagramPresenter, mouseState, selectedShapeAtCursorInfo))
								return Action.MoveHandle;
							else
								return Action.SelectWithFrame;
						}
						else {
							// If there is no shape under the cursor, start a SelectWithFrame action,
							// otherwise start a MoveShape action
							bool canMove = false;
							if (!selectedShapeAtCursorInfo.IsEmpty) {
								// If there are selected shapes, check these shapes...
								canMove = IsMoveShapeFeasible(diagramPresenter, mouseState, selectedShapeAtCursorInfo);
							}
							else {
								// ... otherwise check the shape under the cursor as it will be selected 
								// before starting a move action
								canMove = IsMoveShapeFeasible(diagramPresenter, mouseState, shapeAtCursorInfo);
							}
							return canMove ? Action.MoveShape : Action.SelectWithFrame;
						}
					}
					else if (mouseState.IsButtonDown(MouseButtonsDg.Right)) {
						if (IsConnectFromShapeFeasible(diagramPresenter, mouseState, shapeAtCursorInfo)) {
							return Action.ConnectShapes;
						}
					}
					return CurrentAction;

				default:
					throw new NShapeUnsupportedValueException(CurrentAction);
			}
		}
开发者ID:stewmc,项目名称:vixen,代码行数:56,代码来源:ConfigFiltersAndPatching-Tools.cs


示例20: PerformMoveHandle

		// apply the resize action
		private bool PerformMoveHandle(IDiagramPresenter diagramPresenter)
		{
			bool result = false;
			Invalidate(diagramPresenter);

			int distanceX = CurrentMouseState.X - ActionStartMouseState.X;
			int distanceY = CurrentMouseState.Y - ActionStartMouseState.Y;

			// if the moved ControlPoint is a single GluePoint, snap to ConnectionPoints
			bool isGluePoint = false;
			if (diagramPresenter.SelectedShapes.Count == 1)
				isGluePoint = selectedShapeAtCursorInfo.Shape.HasControlPointCapability(selectedShapeAtCursorInfo.ControlPointId,
				                                                                        ControlPointCapabilities.Glue);

			// Snap to Grid or ControlPoint
			bool calcSnapDistance = true;
			ShapeAtCursorInfo targetShapeInfo = ShapeAtCursorInfo.Empty;
			if (isGluePoint) {
				Point currentPtPos =
					selectedShapeAtCursorInfo.Shape.GetControlPointPosition(selectedShapeAtCursorInfo.ControlPointId);
				Point newPtPos = Point.Empty;
				newPtPos.Offset(currentPtPos.X + distanceX, currentPtPos.Y + distanceY);
				targetShapeInfo = FindConnectionTarget(ActionDiagramPresenter, selectedShapeAtCursorInfo.Shape,
				                                       selectedShapeAtCursorInfo.ControlPointId, newPtPos, true, true);
				if (!targetShapeInfo.IsEmpty) {
					// If there is a target shape to connect to, get the position of the target connection point 
					// and move the gluepoint exactly to this position
					calcSnapDistance = false;
					if (targetShapeInfo.ControlPointId != ControlPointId.Reference) {
						Point pt = targetShapeInfo.Shape.GetControlPointPosition(targetShapeInfo.ControlPointId);
						distanceX = pt.X - currentPtPos.X;
						distanceY = pt.Y - currentPtPos.Y;
					}
					else {
						// If the target point is the reference point, use the previously calculated snap distance
						// ToDo: We need a solution for calculating the nearest point on the target shape's outline
						distanceX += snapDeltaX;
						distanceY += snapDeltaY;
					}
				}
			}
			if (calcSnapDistance) {
				FindNearestSnapPoint(diagramPresenter, selectedShapeAtCursorInfo.Shape, selectedShapeAtCursorInfo.ControlPointId,
				                     distanceX, distanceY, out snapDeltaX, out snapDeltaY);
				distanceX += snapDeltaX;
				distanceY += snapDeltaY;
			}

			ResizeModifiers resizeModifier = GetResizeModifier(CurrentMouseState);
			if (isGluePoint) {
				ICommand cmd = new MoveGluePointCommand(selectedShapeAtCursorInfo.Shape, selectedShapeAtCursorInfo.ControlPointId,
				                                        targetShapeInfo.Shape, targetShapeInfo.ControlPointId, distanceX, distanceY,
				                                        resizeModifier);
				diagramPresenter.Project.ExecuteCommand(cmd);
			}
			else {
				ICommand cmd = new MoveControlPointCommand(ActionDiagramPresenter.SelectedShapes,
				                                           selectedShapeAtCursorInfo.ControlPointId, distanceX, distanceY,
				                                           resizeModifier);
				diagramPresenter.Project.ExecuteCommand(cmd);
			}

			snapDeltaX = snapDeltaY = 0;
			snapPtId = ControlPointId.None;
			result = true;

			return result;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:69,代码来源:ConfigFiltersAndPatching-Tools.cs



注:本文中的IDiagramPresenter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDialogModule类代码示例发布时间:2022-05-24
下一篇:
C# IDeviceContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap