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


C# IDiagramPresenter.ControlToDiagram方法代码示例

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


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

示例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;

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

示例4: InvalidateAnglePreview

		private void InvalidateAnglePreview(IDiagramPresenter diagramPresenter) {
			// invalidate previous angle preview
			diagramPresenter.InvalidateDiagram(
				rectBuffer.X - rectBuffer.Width - diagramPresenter.GripSize,
				rectBuffer.Y - rectBuffer.Height - diagramPresenter.GripSize,
				rectBuffer.Width + rectBuffer.Width + (2 * diagramPresenter.GripSize),
				rectBuffer.Height + rectBuffer.Height + (2 * diagramPresenter.GripSize));

			int requiredDistance;
			diagramPresenter.ControlToDiagram(diagramPresenter.MinRotateRange, out requiredDistance);
			int length = (int)Math.Round(Geometry.DistancePointPoint(ActionStartMouseState.X, ActionStartMouseState.Y, CurrentMouseState.X, CurrentMouseState.Y));

			// invalidate current angle preview / instruction preview
			rectBuffer.Location = ActionStartMouseState.Position;
			if (length > requiredDistance)
				rectBuffer.Width = rectBuffer.Height = length;
			else
				rectBuffer.Width = rectBuffer.Height = requiredDistance;
			diagramPresenter.InvalidateDiagram(rectBuffer.X - rectBuffer.Width, rectBuffer.Y - rectBuffer.Height, rectBuffer.Width + rectBuffer.Width, rectBuffer.Height + rectBuffer.Height);
		}
开发者ID:jestonitiro,项目名称:nshape,代码行数:20,代码来源:Tool.cs

示例5: Invalidate

        /// <override></override>
        public override void Invalidate(IDiagramPresenter diagramPresenter)
        {
            if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
            int x = int.MaxValue;
            int y = int.MaxValue;
            int width = int.MinValue;
            int height = int.MinValue;
            if (strokeSet.Count > 0)
                GetStrokeSetBounds(out x, out y, out width, out height);

            // invalidate Stroke(s)
            foreach (Point p in currentStroke) {
                if (p.X < x) x = p.X;
                if (p.Y < y) y = p.Y;
                if (p.X > x + width) width = p.X - x;
                if (p.Y > y + height) height = p.Y - y;
            }
            if (diagramPresenter != null) {
                diagramPresenter.ControlToDiagram(rect, out rect);
                if (strokeSet.Count > 0 || currentStroke.Count > 0)
                    diagramPresenter.InvalidateDiagram(x, y, width, height);
            }
        }
开发者ID:kjburns31,项目名称:vixen-modules,代码行数:24,代码来源:FreeHandTool.cs


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