public void Execute() { StageView stage = MainForm.CurrentStage; InstanceGroup sel = stage.Selection; prevSelected = sel.SelectedIds; if (instanceIds == null) { instanceIds = stage.AddInstances(libraryIds, locations); } else { stage.AddInstancesById(instanceIds); } sel.Set(instanceIds); stage.ResetTransformHandles(); stage.InvalidateTransformedSelection(); }
public void Execute() { StageView stage = MainForm.CurrentStage; InstanceGroup sel = stage.Selection; this.prevSelected = sel.SelectedIds; Vex.Point selRotCent = sel.GlobalRotationCenter.Translate(sel.Location.Negate()); uint[] libraryIds = new uint[prevSelected.Length]; Vex.Point[] locations = new Vex.Point[prevSelected.Length]; for (int i = 0; i < prevSelected.Length; i++) { DesignInstance di = MainForm.CurrentInstanceManager[prevSelected[i]]; libraryIds[i] = di.LibraryItem.DefinitionId; locations[i] = new Vex.Point(di.Location.X + offset.X, di.Location.Y + offset.Y); } if (newInstanceIds == null) { newInstanceIds = stage.AddInstances(libraryIds, locations); for (int i = 0; i < newInstanceIds.Length; i++) { DesignInstance oldDi = MainForm.CurrentInstanceManager[prevSelected[i]]; DesignInstance newDi = MainForm.CurrentInstanceManager[newInstanceIds[i]]; Vex.Matrix m = oldDi.GetMatrix(); stage.SetDesignInstanceMatrix(newDi, new Vex.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, newDi.Location.X, newDi.Location.Y)); newDi.RotationCenter = oldDi.RotationCenter; } } else { stage.AddInstancesById(newInstanceIds); } sel.Set(newInstanceIds); sel.GlobalRotationCenter = selRotCent.Translate(sel.Location); stage.ResetTransformHandles(); stage.InvalidateTransformedSelection(); }