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

C# Utilities.Point2D类代码示例

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

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



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


示例16: 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
                if (!_nodes.Any()) return;

                List<NodeModel> nodes = _nodes.Select(x => x.NodeModel).Where(x => x != null).ToList();
                minX = nodes.Select(x => x.X).Min();
                maxX = nodes.Select(x => x.X + x.Width).Max();
                minY = nodes.Select(y => y.Y).Min();
                maxY = nodes.Select(y => y.Y + y.Height).Max();
            }

            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:jimb000,项目名称:Dynamo,代码行数:35,代码来源:WorkspaceViewModel.cs


示例17: PasteSelection

 internal void PasteSelection(Point2D targetPoint)
 {
     stateMachine.PasteSelection(targetPoint);
 }
开发者ID:sm6srw,项目名称:Dynamo,代码行数:4,代码来源:StateMachine.cs


示例18: DragAndDrop

        /// <summary>
        /// Drag and drop nodes, notes, annotations and connectors.
        /// </summary>
        /// <param name="mouse">Relative position to WorkspaceElements</param>
        private void DragAndDrop(Point mouse)
        {
            // disable clearing selection while dragged data is being generated
            // new AnnotationViewModel unnecessarily clears selection 
            DynamoSelection.Instance.ClearSelectionDisabled = true;
            var selection = DynamoSelection.Instance.Selection;
            var nodes = selection.OfType<NodeModel>();
            var notes = selection.OfType<NoteModel>();
            var annotations = selection.OfType<AnnotationModel>();

            var connectors = nodes.SelectMany(n =>
                n.OutPorts.SelectMany(port => port.Connectors)
                    .Where(c => c.End != null && c.End.Owner.IsSelected)).Distinct();

            // set list of selected viewmodels
            draggedData = connectors.Select(c => (ViewModelBase)new ConnectorViewModel(ViewModel, c))
                .Concat(notes.Select(n => new NoteViewModel(ViewModel, n)))
                .Concat(annotations.Select(a => new AnnotationViewModel(ViewModel, a)))
                .Concat(nodes.Select(n =>
                {
                    var node = this.ChildrenOfType<NodeView>()
                        .FirstOrDefault(view => view.ViewModel.NodeModel == n);
                    if (node == null) return new NodeViewModel(ViewModel, n);

                    var nodeRect = node.nodeBorder;
                    var size = new Size(nodeRect.ActualWidth, nodeRect.ActualHeight);
                    // set fixed size for dragged nodes, 
                    // so that they will correspond to origin nodes
                    return new NodeViewModel(ViewModel, n, size);
                })).ToList();
            
            var locatableModels = nodes.Concat<ModelBase>(notes);
            var minX = locatableModels.Any() ? locatableModels.Min(mb => mb.X) : 0;
            var minY = locatableModels.Any() ? locatableModels.Min(mb => mb.Y) : 0;
            // compute offset to correctly place selected items right under mouse cursor 
            var mouseOffset = new Point2D(mouse.X - minX, mouse.Y - minY);

            DynamoSelection.Instance.ClearSelectionDisabled = false;
            DragDrop.DoDragDrop(this, mouseOffset, DragDropEffects.Copy);

            // remove dragged selection view 
            if (draggedAdorner != null)
            {
                draggedData = null;
                draggedAdorner.Detach();
                draggedAdorner = null;
            }
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:52,代码来源:WorkspaceView.xaml.cs


示例19: DraggedNode

 /// <summary>
 /// Construct a DraggedNode for a given ILocatable object.
 /// </summary>
 /// <param name="locatable">The ILocatable (usually a node) that is 
 /// associated with this DraggedNode object. During an update, the 
 /// position of ILocatable will be updated based on the specified 
 /// mouse position and the internal delta values.</param>
 /// <param name="mouseCursor">The mouse cursor at the point this 
 /// DraggedNode object is constructed. This is used to determine the 
 /// offset of the ILocatable from the mouse cursor.</param>
 /// <param name="region">The region within which the ILocatable can 
 /// be moved. However, the movement of ILocatable will be limited by 
 /// region and that it cannot be moved beyond the region.</param>
 /// 
 public DraggedNode(ILocatable locatable, Point2D mouseCursor)
 {
     this.locatable = locatable;
     deltaX = mouseCursor.X - locatable.X;
     deltaY = mouseCursor.Y - locatable.Y;
 }
开发者ID:sm6srw,项目名称:Dynamo,代码行数:20,代码来源:StateMachine.cs


示例20: ZoomAtViewportPoint

        private void ZoomAtViewportPoint(double zoom, Point2D relative)
        {
            // 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;

            double absoluteX, absoluteY;
            absoluteX = relative.X * ViewModel.Model.Zoom + ViewModel.Model.X;
            absoluteY = relative.Y * ViewModel.Model.Zoom + ViewModel.Model.Y;
            var resultOffset = new Point2D();
            resultOffset.X = absoluteX - (relative.X * resultZoom);
            resultOffset.Y = absoluteY - (relative.Y * resultZoom);

            ViewModel.Model.Zoom = resultZoom;
            ViewModel.Model.X = resultOffset.X;
            ViewModel.Model.Y = resultOffset.Y;

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ViewModels.DynamoViewModel类代码示例发布时间:2022-05-24
下一篇:
C# Utilities.CustomNodeInfo类代码示例发布时间: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