//-------------------------------------------------------------------------------------------------- #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(); }
//-------------------------------------------------------------------------------------------------- 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 }); }