当前位置: 首页>>代码示例>>C#>>正文


C# IDiagramPresenter.SetCursor方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: StartToolAction

		/// <override></override>
		protected override void StartToolAction(IDiagramPresenter diagramPresenter, int action, MouseState mouseState, bool wantAutoScroll) {
			base.StartToolAction(diagramPresenter, action, mouseState, wantAutoScroll);
			CreatePreview(ActionDiagramPresenter);
			PreviewShape.DisplayService = diagramPresenter.DisplayService;
			PreviewShape.MoveTo(mouseState.X, mouseState.Y);
			drawPreview = true;
			diagramPresenter.SetCursor(CurrentCursorId);
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:9,代码来源:Tool.cs

示例6: ProcessMouseMove

		private bool ProcessMouseMove(IDiagramPresenter diagramPresenter, MouseState mouseState) {
			bool result = false;
			ShapeAtCursorInfo shapeAtCursorInfo = ShapeAtCursorInfo.Empty;
			if (pointAtCursor != ControlPointId.None && ((modifiedLinearShape as Shape) != null || PreviewShape != null))
				shapeAtCursorInfo = FindConnectionTarget(diagramPresenter, (modifiedLinearShape as Shape) ?? PreviewShape, pointAtCursor, mouseState.Position, false, true);
			else shapeAtCursorInfo = FindShapeAtCursor(diagramPresenter, mouseState.X, mouseState.Y, ControlPointCapabilities.Connect | ControlPointCapabilities.Glue, diagramPresenter.ZoomedGripSize, false);

			// set cursor depending on the object under the mouse cursor
			int currentCursorId = DetermineCursor(diagramPresenter, shapeAtCursorInfo.Shape, shapeAtCursorInfo.ControlPointId);
			if (CurrentAction == Action.None)
				diagramPresenter.SetCursor(currentCursorId);
			else ActionDiagramPresenter.SetCursor(currentCursorId);

			switch (CurrentAction) {
				case Action.None:
					Invalidate(diagramPresenter);
					break;

				case Action.CreateLine:
				case Action.ExtendLine:
					Invalidate(ActionDiagramPresenter);

					// Check for connectionpoints wihtin the snapArea
					ResizeModifiers resizeModifier = GetResizeModifier(mouseState);
					if (!shapeAtCursorInfo.IsEmpty) {
						Point p = Point.Empty;
						if (shapeAtCursorInfo.IsCursorAtGrip)
							p = shapeAtCursorInfo.Shape.GetControlPointPosition(shapeAtCursorInfo.ControlPointId);
						else p = mouseState.Position;
#if DEBUG_DIAGNOSTICS
						Assert(PreviewShape != null);
#endif
						if (PreviewShape != null)
							PreviewShape.MoveControlPointTo(pointAtCursor, p.X, p.Y, resizeModifier);
					} else {
						int snapDeltaX = 0, snapDeltaY = 0;
						if (diagramPresenter.SnapToGrid)
							FindNearestSnapPoint(diagramPresenter, mouseState.X, mouseState.Y, out snapDeltaX, out snapDeltaY);
#if DEBUG_DIAGNOSTICS
						Assert(PreviewShape != null);
#endif
						if (PreviewShape != null)
							PreviewShape.MoveControlPointTo(pointAtCursor, mouseState.X + snapDeltaX, mouseState.Y + snapDeltaY, resizeModifier);
					}
					Invalidate(ActionDiagramPresenter);
					break;

				default: throw new NShapeUnsupportedValueException(CurrentAction);
			}
			return result;
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:51,代码来源:Tool.cs

示例7: 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
					ShapeAtCursorInfo shapeAtCursorInfo = ShapeAtCursorInfo.Empty;
					if (!SelectedShapeAtCursorInfo.IsEmpty) {
						if (SelectedShapeAtCursorInfo.Shape.ContainsPoint(mouseState.X, mouseState.Y)) {
							Shape shape = ActionDiagramPresenter.Diagram.Shapes.FindShape(mouseState.X, mouseState.Y, ControlPointCapabilities.None, 0, SelectedShapeAtCursorInfo.Shape);
							if (shape != null) {
								shapeAtCursorInfo.Shape = shape;
								shapeAtCursorInfo.ControlPointId = shape.HitTest(mouseState.X, mouseState.Y, ControlPointCapabilities.None, 0);
								shapeAtCursorInfo.CaptionIndex = -1;
							}
						}
					} else 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.EditCaption:
					// if the user clicked a caption, display the caption editor
#if DEBUG_DIAGNOSTICS
					Assert(SelectedShapeAtCursorInfo.IsCursorAtCaption);
#endif
					ActionDiagramPresenter.OpenCaptionEditor((ICaptionedShape)SelectedShapeAtCursorInfo.Shape, SelectedShapeAtCursorInfo.CaptionIndex);
					EndToolAction();
					result = true;
					break;

				case Action.MoveHandle:
#if DEBUG_DIAGNOSTICS
					Assert(!SelectedShapeAtCursorInfo.IsEmpty);
#endif
					result = PerformMoveHandle(ActionDiagramPresenter);
					while (IsToolActionPending)
						EndToolAction();
					break;

				case Action.MoveShape:
#if DEBUG_DIAGNOSTICS
					Assert(!SelectedShapeAtCursorInfo.IsEmpty);
#endif
					result = PerformMoveShape(ActionDiagramPresenter);
					while (IsToolActionPending)
						EndToolAction();
					break;

				case Action.PrepareRotate:
				case Action.Rotate:
#if DEBUG_DIAGNOSTICS
					Assert(!SelectedShapeAtCursorInfo.IsEmpty);
#endif
					if (CurrentAction == Action.Rotate)
						result = PerformRotate(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:jestonitiro,项目名称:nshape,代码行数:86,代码来源:Tool.cs


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