/// <summary> /// Group all selected layerages. /// </summary> public static void GroupAllSelectedLayers() { // Layerages IEnumerable <Layerage> selectedLayerages = LayerManager.GetAllSelected(); Layerage outermost = LayerManager.FindOutermostLayerage(selectedLayerages); if (outermost is null) { return; } Layerage parents = LayerManager.GetParentsChildren(outermost); int index = parents.Children.IndexOf(outermost); if (index < 0) { index = 0; } // GroupLayer Layerage groupLayerage = Layerage.CreateByGuid(); GroupLayer groupLayer = new GroupLayer { Id = groupLayerage.Id, IsSelected = true, IsExpand = false, // Refactoring IsRefactoringTransformer = true, }; LayerBase.Instances.Add(groupLayerage.Id, groupLayer); // Temp foreach (Layerage layerage in selectedLayerages) { ILayer layer = layerage.Self; Layerage childParents = LayerManager.GetParentsChildren(layerage); childParents.Children.Remove(layerage); layer.IsSelected = false; groupLayerage.Children.Add(layerage); } // Insert parents.Children.Insert(index, groupLayerage); }
private static void PasteLayerageCore(IList <Layerage> children) { for (int i = 0; i < children.Count; i++) { Layerage child = children[i]; LayerManager.PasteLayerageCore(child.Children); // ILayer childCopy = child.ClipboardSelf; ILayer cloneLayer = childCopy.Clone(); Layerage cloneLayerage = Layerage.CreateByGuid(); cloneLayer.Id = cloneLayerage.Id; LayerBase.Instances.Add(cloneLayerage.Id, cloneLayer); // children[i].Id = cloneLayerage.Id; } }
/// <summary> /// Paste a layerage ( form Clipboard to Layerbase). /// </summary> /// <param name="layerage"> The layerage. </param> public static Layerage PasteLayerage(Layerage layerage) { Layerage child = layerage.Clone(); // ILayer childCopy = child.ClipboardSelf; ILayer cloneLayer = childCopy.Clone(); Layerage cloneLayerage = Layerage.CreateByGuid(); cloneLayer.Id = cloneLayerage.Id; LayerBase.Instances.Add(cloneLayerage.Id, cloneLayer); // cloneLayerage.Children = child.Children; child.Children = null; LayerManager.PasteLayerageCore(cloneLayerage.Children); return(cloneLayerage); }