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


C# Utilities.Point2D类代码示例

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


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

示例1: ZoomEventArgs

 internal ZoomEventArgs(Point2D offset, double focusWidth, double focusHeight)
 {
     this.Offset = offset;
     this.FocusWidth = focusWidth;
     this.FocusHeight = focusHeight;
     this.Modes = ZoomModes.ByFitView;
 }
开发者ID:junmendoza,项目名称:Dynamo,代码行数:7,代码来源:DynamoModelEventArgs.cs

示例2: Rect2D

		public Rect2D (Point2D point1, Point2D point2)
		{
			if (point1.X < point2.X) {
				x = point1.X;
				width = point2.X - point1.X;
			}
			else {
				x = point2.X;
				width = point1.X - point2.X;
			}

			if (point1.Y < point2.Y) {
				y = point1.Y;
				height = point2.Y - point1.Y;
			}
			else {
				y = point2.Y;
				height = point1.Y - point2.Y;
			}
		}
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:20,代码来源:Rect2D.cs

示例3: PointEventArgs

 public PointEventArgs(Point2D p)
 {
     Point = p;
 }
开发者ID:junmendoza,项目名称:Dynamo,代码行数:4,代码来源:DynamoModelEventArgs.cs

示例4: Paste

        /// <summary>
        ///     Paste ISelectable objects from the clipboard to the workspace
        /// so that the nodes appear in their original location with a slight offset
        /// </summary>
        public void Paste()
        {
            var locatableModels = ClipBoard.Where(model => model is NoteModel || model is NodeModel);
            var x = locatableModels.Min(m => m.X);
            var y = locatableModels.Min(m => m.Y);
            var targetPoint = new Point2D(x, y);

            Paste(targetPoint);
        }
开发者ID:ksobon,项目名称:Dynamo,代码行数:13,代码来源:DynamoModel.cs

示例5: OnWorkspaceDrop

        private void OnWorkspaceDrop(object sender, DragEventArgs e)
        {
            var mousePosition = e.GetPosition(WorkspaceElements);
            var pointObj = e.Data.GetData(typeof(Point2D));
            if (pointObj is Point2D)
            {
                var offset = (Point2D)pointObj;
                // compute a point where (minX, minY) will be pasted -
                // location of selection top left corner
                var targetX = mousePosition.X - offset.X;
                var targetY = mousePosition.Y - offset.Y;
                var targetPoint = new Point2D(targetX, targetY);

                ViewModel.PasteSelection(targetPoint);

                return;
            }

            var nodeInfo = e.Data.GetData(typeof(DragDropNodeSearchElementInfo)) as DragDropNodeSearchElementInfo;
            if (nodeInfo == null)
                return;

            var nodeModel = nodeInfo.SearchElement.CreateNode();
            ViewModel.DynamoViewModel.ExecuteCommand(new DynamoModel.CreateNodeCommand(
                nodeModel, mousePosition.X, mousePosition.Y, false, true));
        }
开发者ID:nmeek,项目名称:Dynamo,代码行数:26,代码来源:WorkspaceView.xaml.cs

示例6: vm_ZoomToFitView

        void vm_ZoomToFitView(object sender, EventArgs e)
        {
            ZoomEventArgs zoomArgs = (e as ZoomEventArgs);

            double viewportPadding = 30;
            double fitWidth = outerCanvas.ActualWidth - 2 * viewportPadding;
            double fitHeight = outerCanvas.ActualHeight - 2 * viewportPadding;

            // Find the zoom required for fitview
            double scaleRequired = 1; // 100% zoom
            if (zoomArgs.hasZoom()) // FitView
                scaleRequired = zoomArgs.Zoom;
            else
            {
                double scaleX = fitWidth / zoomArgs.FocusWidth;
                double scaleY = fitHeight / zoomArgs.FocusHeight;
                scaleRequired = scaleX > scaleY ? scaleY : scaleX; // get least zoom required
            }

            // Limit Zoom
            if (scaleRequired > WorkspaceModel.ZOOM_MAXIMUM)
                scaleRequired = WorkspaceModel.ZOOM_MAXIMUM;
            else if (scaleRequired < WorkspaceModel.ZOOM_MINIMUM)
                scaleRequired = WorkspaceModel.ZOOM_MINIMUM;

            // Center position
            double centerOffsetX = viewportPadding + (fitWidth - (zoomArgs.FocusWidth * scaleRequired)) / 2;
            double centerOffsetY = viewportPadding + (fitHeight - (zoomArgs.FocusHeight * scaleRequired)) / 2;

            var resultOffset = new Point2D();
            resultOffset.X = -(zoomArgs.Offset.X * scaleRequired) + centerOffsetX;
            resultOffset.Y = -(zoomArgs.Offset.Y * scaleRequired) + centerOffsetY;

            // Apply on model
            ViewModel.Model.Zoom = scaleRequired;
            ViewModel.Model.X = resultOffset.X;
            ViewModel.Model.Y = resultOffset.Y;

            vm_CurrentOffsetChanged(this, new PointEventArgs(resultOffset));
            vm_ZoomChanged(this, new ZoomEventArgs(scaleRequired));
        }
开发者ID:nmeek,项目名称:Dynamo,代码行数:41,代码来源:WorkspaceView.xaml.cs

示例7: vm_ZoomAtViewportCenter

        void vm_ZoomAtViewportCenter(object sender, EventArgs e)
        {
            double zoom = AdjustZoomForCurrentZoomAmount((e as ZoomEventArgs).Zoom);

            // Limit Zoom
            double resultZoom = ViewModel.Model.Zoom + zoom;
            if (resultZoom < WorkspaceModel.ZOOM_MINIMUM)
                resultZoom = WorkspaceModel.ZOOM_MINIMUM;
            else if (resultZoom > WorkspaceModel.ZOOM_MAXIMUM)
                resultZoom = WorkspaceModel.ZOOM_MAXIMUM;

            // Get Viewpoint Center point
            var centerPoint = new Point2D();
            centerPoint.X = outerCanvas.ActualWidth / 2;
            centerPoint.Y = outerCanvas.ActualHeight / 2;

            // Get relative point of ZoomBorder child in relates to viewpoint center point
            var relativePoint = new Point2D();
            relativePoint.X = (centerPoint.X - ViewModel.Model.X) / ViewModel.Model.Zoom;
            relativePoint.Y = (centerPoint.Y - ViewModel.Model.Y) / ViewModel.Model.Zoom;

            ZoomAtViewportPoint(zoom, relativePoint);
        }
开发者ID:nmeek,项目名称:Dynamo,代码行数:23,代码来源:WorkspaceView.xaml.cs

示例8: TestDraggedNode

        public void TestDraggedNode()
        {
            var addNode = new DSFunction(ViewModel.Model.LibraryServices.GetFunctionDescriptor("+")) { X = 16, Y = 32 };
            ViewModel.Model.CurrentWorkspace.AddNode(addNode, false);
            NodeModel locatable = ViewModel.Model.CurrentWorkspace.Nodes[0];

            var startPoint = new Point2D(8, 64);
            var dn = new WorkspaceViewModel.DraggedNode(locatable, startPoint);

            // Initial node position.
            Assert.AreEqual(16, locatable.X);
            Assert.AreEqual(32, locatable.Y);

            // Move the mouse cursor to move node.
            dn.Update(new Point2D(-16, 72));
            Assert.AreEqual(-8, locatable.X);
            Assert.AreEqual(40, locatable.Y);
        }
开发者ID:yy-yyaa,项目名称:Dynamo,代码行数:18,代码来源:CoreUITests.cs

示例9: Paste

        /// <summary>
        ///     Paste ISelectable objects from the clipboard to the workspace 
        /// so that the nodes appear in their original location with a slight offset
        /// </summary>
        public void Paste()
        {
            // Provide a small offset when pasting so duplicate pastes aren't directly on top of each other
            CurrentWorkspace.IncrementPasteOffset();

            var locatableModels = ClipBoard.Where(model => model is NoteModel || model is NodeModel);
            var orderedItems = locatableModels.OrderBy(item => item.CenterX + item.CenterY);

            // Search for the rightmost item. It's item with the biggest X, Y coordinates of center.
            var rightMostItem = orderedItems.Last();

            // Search for the leftmost item. It's item with the smallest X, Y coordinates of center.
            var leftMostItem = orderedItems.First();

            // Compute shift so that left most item will appear at right most item place with offset.
            var shiftX = rightMostItem.X + rightMostItem.Width + CurrentWorkspace.CurrentPasteOffset - leftMostItem.X;
            var shiftY = rightMostItem.Y + CurrentWorkspace.CurrentPasteOffset - leftMostItem.Y;


            var x = shiftX + locatableModels.Min(m => m.X);
            var y = shiftY + locatableModels.Min(m => m.Y);
            var targetPoint = new Point2D(x, y);
            
            Paste(targetPoint);
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:29,代码来源:DynamoModel.cs

示例10: UpdateDraggedSelection

        internal void UpdateDraggedSelection(Point2D mouseCursor)
        {
            if (draggedNodes.Count <= 0)
            {
                throw new InvalidOperationException(
                    "UpdateDraggedSelection cannot be called now");
            }

            foreach (DraggedNode draggedNode in draggedNodes)
                draggedNode.Update(mouseCursor);
        }
开发者ID:sm6srw,项目名称:Dynamo,代码行数:11,代码来源:StateMachine.cs

示例11: FitViewInternal

        internal void FitViewInternal()
        {
            // Get the offset and focus width & height (zoom if 100%)
            double minX, maxX, minY, maxY;

            // Get the width and height of area to fit
            if (DynamoSelection.Instance.Selection.Count > 0)
            {   // has selection
                minX = GetSelectionMinX();
                maxX = GetSelectionMaxX();
                minY = GetSelectionMinY();
                maxY = GetSelectionMaxY();
            }
            else
            {   
                // no selection, fitview all nodes and notes
                var nodes = _nodes.Select(x => x.NodeModel);
                var notes = _notes.Select(x => x.Model);
                var models = nodes.Concat<ModelBase>(notes);

                if (!models.Any()) return;

                // initialize to the first model (either note or node) on the list 

                var firstModel = models.First();
                minX = firstModel.X;
                maxX = firstModel.X;
                minY = firstModel.Y;
                maxY = firstModel.Y;

                foreach (var model in models)
                {
                    //calculates the min and max positions of both x and y coords of all nodes and notes
                    minX = Math.Min(model.X, minX);
                    maxX = Math.Max(model.X + model.Width, maxX);
                    minY = Math.Min(model.Y, minY);
                    maxY = Math.Max(model.Y + model.Height, maxY);
                }
                
            }

            var offset = new Point2D(minX, minY);
            double focusWidth = maxX - minX;
            double focusHeight = maxY - minY;

            _fitViewActualZoomToggle = !_fitViewActualZoomToggle;
            ZoomEventArgs zoomArgs = _fitViewActualZoomToggle
                ? new ZoomEventArgs(offset, focusWidth, focusHeight)
                : new ZoomEventArgs(offset, focusWidth, focusHeight, 1.0);

            OnRequestZoomToFitView(this, zoomArgs);
        }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:52,代码来源:WorkspaceViewModel.cs

示例12: UndoMovingNoteInsideGroup

        public void UndoMovingNoteInsideGroup()
        {
            OpenModel(@"UI\NoteInGroupTest.dyn");

            var workspaceVm = ViewModel.CurrentSpaceViewModel;

            // check if note is loaded from the file
            var noteVm = workspaceVm.Notes.First();
            Assert.IsNotNull(noteVm);
            var noteX = noteVm.Left;
            var noteY = noteVm.Top;
            var noteCenterX = noteVm.Model.CenterX;
            var noteCenterY = noteVm.Model.CenterY;

            // check if group is loaded from the file
            var groupVm = workspaceVm.Annotations.First();
            Assert.IsNotNull(groupVm);
            var groupX = groupVm.Left;
            var groupY = groupVm.Top;

            // only note should be selected
            DynamoSelection.Instance.Selection.Add(noteVm.Model);

            var point = new Point2D(noteCenterX, noteCenterY);
            var operation = DynamoModel.DragSelectionCommand.Operation.BeginDrag;
            var command = new DynamoModel.DragSelectionCommand(point, operation);

            ViewModel.ExecuteCommand(command);

            operation = DynamoModel.DragSelectionCommand.Operation.EndDrag;
            point.X += 100;
            point.Y += 100;
            command = new DynamoModel.DragSelectionCommand(point, operation);

            ViewModel.ExecuteCommand(command);

            // Check note and annotation are moved
            Assert.AreNotEqual(groupX, groupVm.Left);
            Assert.AreNotEqual(groupY, groupVm.Top);
            Assert.AreNotEqual(noteX, noteVm.Left);
            Assert.AreNotEqual(noteY, noteVm.Top);

            ViewModel.UndoCommand.Execute(null);

            // Check annotation and note are moved back
            var msgPart = " was not moved back";
            Assert.AreEqual(groupX, groupVm.Left, "Group" + msgPart);
            Assert.AreEqual(groupY, groupVm.Top, "Group" + msgPart);
            Assert.AreEqual(noteX, noteVm.Left, "Note" + msgPart);
            Assert.AreEqual(noteY, noteVm.Top, "Note" + msgPart);
        }
开发者ID:MrWalsh,项目名称:Dynamo,代码行数:51,代码来源:AnnotationViewModelTests.cs

示例13: SetTranslateTransformOrigin

        public void SetTranslateTransformOrigin(Point2D p)
        {
            var tt = GetTranslateTransform(child);
            tt.X = p.X;
            tt.Y = p.Y;

            var st = GetScaleTransform(child);
            NotifyViewSettingsChanged(tt.X, tt.Y, st.ScaleX);
        }
开发者ID:jimb000,项目名称:Dynamo,代码行数:9,代码来源:ZoomBorder.cs

示例14: DragSelectionCommand

 /// <summary>
 ///
 /// </summary>
 /// <param name="mouseCursor"></param>
 /// <param name="operation"></param>
 public DragSelectionCommand(Point2D mouseCursor, Operation operation)
 {
     MouseCursor = mouseCursor;
     DragOperation = operation;
 }
开发者ID:Randy-Ma,项目名称:Dynamo,代码行数:10,代码来源:RecordableCommands.cs

示例15: EndDragSelection

 internal void EndDragSelection(Point2D mouseCursor)
 {
     UpdateDraggedSelection(mouseCursor); // Final position update.
     draggedNodes.Clear(); // We are no longer dragging anything.
 }
开发者ID:sm6srw,项目名称:Dynamo,代码行数:5,代码来源:StateMachine.cs


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