コード例 #1
0
ファイル: SketchSplitTests.cs プロジェクト: Macad3D/Macad3D
        public void SplitPoint()
        {
            var sketch = TestSketchGenerator.CreateSketch(TestSketchGenerator.SketchType.Rectangle);

            Assert.IsTrue(SketchUtils.CanSplitPoint(sketch, 0));
            var newPoints = SketchUtils.SplitPoint(sketch, 0);

            Assert.That(newPoints.SequenceEqual(new[] { 4 }));
            Assert.AreEqual(5, sketch.Points.Count);

            Assert.AreEqual(4, sketch.Segments[0].StartPoint);
            Assert.AreEqual(0, sketch.Segments[3].EndPoint);
            Assert.IsFalse(SketchUtils.CanSplitPoint(sketch, 0));
        }
コード例 #2
0
        //--------------------------------------------------------------------------------------------------

        void _PointAction_Finished(ToolAction toolAction)
        {
            if (_PointAction.SelectedElementType == Sketch.ElementType.Segment && _PointAction.SelectedSegment != null)
            {
                _SketchEditorTool.Sketch.SaveUndo(Sketch.ElementType.All);
                if (SketchUtils.SplitSegment(_SketchEditorTool.Sketch, _PointAction.SelectedSegment, _PointAction.SelectedParameter) != SketchUtils.SplitSegmentFailed)
                {
                    InteractiveContext.Current.UndoHandler.Commit();
                }
            }
            else if (_PointAction.SelectedElementType == Sketch.ElementType.Point && _PointAction.SelectedPointIndex > -1)
            {
                _SketchEditorTool.Sketch.SaveUndo(Sketch.ElementType.Point | Sketch.ElementType.Segment);
                if (SketchUtils.SplitPoint(_SketchEditorTool.Sketch, _PointAction.SelectedPointIndex) != SketchUtils.SplitPointFailed)
                {
                    InteractiveContext.Current.UndoHandler.Commit();
                }
            }

            _PointAction.Reset();
            _SketchEditorTool.StatusText = _Message;
        }