public void Execute() { StageView stage = MainForm.CurrentStage; for (int i = 0; i < defintions.Length; i++) { LibraryItem li = stage.CreateLibraryItem(defintions[i], true); newLibraryItemId = li.DefinitionId; stage.Library.AddLibraryItem(li); LibraryView.CurrentLibraryView.AddItemToLibrary(li); } }
public void Execute() { StageView stage = MainForm.CurrentStage; // store old selection prevSelected = stage.Selection.IdsByDepth;// SelectedIds; prevOffset = stage.Selection.StrokeBounds.Point; // create symbol from selected Vex.Timeline tl = new Vex.Timeline(stage.Library.NextLibraryId()); tl.Name = stage.Library.GetNextDefaultName(); tl.StrokeBounds = stage.Selection.StrokeBounds.TranslatedRectangle(-prevOffset.X, -prevOffset.Y); // delete old symbols DesignInstance[] oldInstances = stage.RemoveInstancesById(prevSelected); for (int i = 0; i < prevSelected.Length; i++) { DesignInstance inst = oldInstances[i];// instMgr[prevSelected[i]]; Vex.Matrix m = inst.GetMatrix(); m.TranslateX -= prevOffset.X; m.TranslateY -= prevOffset.Y; inst.SetMatrix(m); tl.AddInstance(inst.Instance); stage.InstanceManager.AddInstance(inst); // reusing, so must readd (todo: don't reuse ids?) } LibraryItem li = stage.CreateLibraryItem(tl, true); newLibraryItemId = li.DefinitionId; stage.Library.AddLibraryItem(li); LibraryView.CurrentLibraryView.AddItemToLibrary(li); // add new symbol to stage DesignInstance di = stage.AddInstance(tl.Id, prevOffset); newInstanceId = di.InstanceHash; // select new symbol stage.Selection.Set(new uint[] { di.InstanceHash }); stage.ResetTransformHandles(); stage.InvalidateSelection(); }