Example #1
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Selection

        void _OnSelectionChanged(ToolAction toolAction)
        {
            if (CurrentTool != null)
            {
                return;
            }

            if (_MoveAction != null)
            {
                _MoveAction.Stop();
                _MoveAction = null;
            }

            _UpdateSelections();

            if (SelectedSegments.Any() || SelectedPoints.Any())
            {
                _MoveAction = new MoveSketchPointAction(this);
                if (!WorkspaceController.StartToolAction(_MoveAction, false))
                {
                    return;
                }
                _MoveAction.Previewed += _OnMoveActionPreview;
                _MoveAction.Finished  += _OnMoveActionFinished;

                var segPoints = SelectedSegments.SelectMany(seg => seg.Points);
                _MoveAction.SetSketchElements(Sketch, SelectedPoints.Union(segPoints).ToList());
            }

            WorkspaceController.Invalidate();
        }
Example #2
0
        //--------------------------------------------------------------------------------------------------

        public override void Delete()
        {
            SelectedConstraints.ForEach(c => Sketch.DeleteConstraint(c));
            SelectedSegments.ForEach(s => Sketch.DeleteSegment(s));
            SelectedPoints.ForEach(p => SketchUtils.DeletePointTrySubstituteSegments(Sketch, p));

            Sketch.SolveConstraints(true);
            InteractiveContext.Current.UndoHandler.Commit();

            Select(null, null);
        }
Example #3
0
 /// <summary>
 /// Selects required segments
 /// </summary>
 protected void SetSegments()
 {
     if (SelectedSegments.Any())
     {
         for (int i = 0; i < SelectedSegments.Count; i++)
         {
             GeometryFigures.Single(t => (int)t.SegmentNumber == SelectedSegments[i]).IsSelected = true;
         }
     }
     else
     {
         ValueSegmentsSelection();
     }
 }
Example #4
0
        //--------------------------------------------------------------------------------------------------

        SketchCloneContent _CreateCloneContentFromSelection()
        {
            var pointIndices = SelectedPoints.Union(SelectedSegments.SelectMany(seg => seg.Points)).ToArray();
            var pointDict    = pointIndices.ToDictionary(index => index, index => Sketch.Points[index]);
            var segmentDict  = SelectedSegmentIndices.ToDictionary(index => index, index => Sketch.Segments[index]);
            var constraints  = Sketch.Constraints.Where(constraint =>
                                                        (constraint.Points == null || pointIndices.ContainsAll(constraint.Points)) &&
                                                        (constraint.Segments == null || SelectedSegmentIndices.ContainsAll(constraint.Segments))).ToArray();

            return(new SketchCloneContent
            {
                Points = pointDict,
                Segments = segmentDict,
                Constraints = constraints
            });
        }
Example #5
0
        //--------------------------------------------------------------------------------------------------

        void _UpdateStatusText()
        {
            if (SelectedSegments.Any() && !SelectedPoints.Any() && !SelectedConstraints.Any())
            {
                StatusText = SelectedSegments.Count == 1 ? string.Format(SegmentSelectedStatusText, SelectedSegments[0].GetType().Name) : string.Format(MultiSegmentSelectedStatusText, SelectedSegments.Count);
            }
            else if (!SelectedSegments.Any() && SelectedPoints.Any() && !SelectedConstraints.Any())
            {
                StatusText = SelectedPoints.Count == 1 ? string.Format(PointSelectedStatusText, SelectedPoints[0]) : string.Format(MultiPointSelectedStatusText, SelectedPoints.Count);
            }
            else if (!SelectedSegments.Any() && !SelectedPoints.Any() && SelectedConstraints.Any())
            {
                StatusText = SelectedConstraints.Count == 1 ? string.Format(ConstraintSelectedStatusText, SelectedConstraints[0].GetType().Name) : string.Format(MultiConstraintSelectedStatusText, SelectedConstraints.Count);
            }
            else
            if (SelectedSegments.Any() || SelectedPoints.Any() || SelectedConstraints.Any())
            {
                StatusText = MixedSelectedStatusText;
            }
            else
            {
                StatusText = UnselectedStatusText;
            }
        }