Exemplo n.º 1
0
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitMakeCompoundPath))
     {
         SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet;
         List <PathElement>       otherElements       = new List <PathElement>();
         foreach (SceneElement element in elementSelectionSet.Selection)
         {
             PathElement pathElement = element as PathElement;
             if (pathElement != null)
             {
                 otherElements.Add(pathElement);
             }
             else if (PathConversionHelper.CanConvert(element))
             {
                 otherElements.Add(PathCommandHelper.ConvertToPath((BaseFrameworkElement)element));
             }
         }
         editTransaction.Update();
         this.DesignerContext.ActiveView.UpdateLayout();
         otherElements.Sort((IComparer <PathElement>) new ZOrderComparer <PathElement>(this.SceneViewModel.RootNode));
         elementSelectionSet.Clear();
         PathElement                      mainElement        = otherElements[0];
         BaseFrameworkElement             frameworkElement   = (BaseFrameworkElement)otherElements[otherElements.Count - 1];
         ISceneNodeCollection <SceneNode> collectionForChild = frameworkElement.ParentElement.GetCollectionForChild((SceneNode)frameworkElement);
         int       num       = collectionForChild.IndexOf((SceneNode)frameworkElement);
         SceneNode sceneNode = num + 1 < collectionForChild.Count ? collectionForChild[num + 1] : (SceneNode)null;
         otherElements.RemoveAt(0);
         PathCommandHelper.MakeCompoundPath(mainElement, otherElements, editTransaction);
         mainElement.Remove();
         if (sceneNode == null)
         {
             collectionForChild.Add((SceneNode)mainElement);
         }
         else
         {
             collectionForChild.Insert(collectionForChild.IndexOf(sceneNode), (SceneNode)mainElement);
         }
         elementSelectionSet.SetSelection((SceneElement)mainElement);
         editTransaction.Commit();
     }
 }