Esempio n. 1
0
        private static SceneElement ChangeLayoutType(SceneElement sourceElement, ITypeId layoutType, ref SceneElement elementContainingChildren)
        {
            IDocumentRoot        documentRoot     = sourceElement.DocumentNode.DocumentRoot;
            IDocumentContext     documentContext  = documentRoot.DocumentContext;
            SceneViewModel       viewModel        = sourceElement.ViewModel;
            Size                 size             = Size.Empty;
            BaseFrameworkElement frameworkElement = sourceElement as BaseFrameworkElement;

            if (frameworkElement != null)
            {
                size = frameworkElement.GetComputedTightBounds().Size;
            }
            using (viewModel.ForceBaseValue())
            {
                SceneElement sceneElement = (SceneElement)viewModel.CreateSceneNode(layoutType);
                using (viewModel.DisableUpdateChildrenOnAddAndRemove())
                {
                    using (viewModel.DisableDrawIntoState())
                    {
                        viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)sourceElement);
                        Dictionary <IPropertyId, SceneNode>         properties     = SceneElementHelper.StoreProperties((SceneNode)sourceElement);
                        Dictionary <IPropertyId, List <SceneNode> > storedChildren = ChangeLayoutTypeCommand.StoreChildren(sourceElement);
                        if (sourceElement.DocumentNode == documentRoot.RootNode)
                        {
                            documentRoot.RootNode = sceneElement.DocumentNode;
                            sceneElement.DocumentNode.NameScope = new DocumentNodeNameScope();
                        }
                        else
                        {
                            ISceneNodeCollection <SceneNode> collectionContainer = sourceElement.GetCollectionContainer();
                            int index = collectionContainer.IndexOf((SceneNode)sourceElement);
                            sourceElement.Remove();
                            collectionContainer.Insert(index, (SceneNode)sceneElement);
                        }
                        SceneElementHelper.ApplyProperties((SceneNode)sceneElement, properties);
                        elementContainingChildren = ChangeLayoutTypeCommand.ApplyChildren(sceneElement, storedChildren, size);
                    }
                }
                if (sceneElement is GridElement || sceneElement is CanvasElement)
                {
                    ILayoutDesigner designerForChild = sceneElement.ViewModel.GetLayoutDesignerForChild(sceneElement, true);
                    if ((designerForChild.GetWidthConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike)
                    {
                        sceneElement.SetValue(BaseFrameworkElement.WidthProperty, (object)size.Width);
                    }
                    if ((designerForChild.GetHeightConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike)
                    {
                        sceneElement.SetValue(BaseFrameworkElement.HeightProperty, (object)size.Height);
                    }
                }
                return(sceneElement);
            }
        }
Esempio n. 2
0
 protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
 {
     if (childCollection.Count == selectedChildren.Count)
     {
         return;
     }
     for (int index = selectedChildren.Count - 1; index >= 0; --index)
     {
         SceneElement sceneElement = selectedChildren[index];
         sceneElement.Remove();
         childCollection.Insert(0, (SceneNode)sceneElement);
     }
 }
Esempio n. 3
0
        protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
        {
            if (childCollection.Count == selectedChildren.Count)
            {
                return;
            }
            int count = childCollection.Count;

            for (int index = 0; index < selectedChildren.Count; ++index)
            {
                SceneElement sceneElement = selectedChildren[index];
                sceneElement.Remove();
                childCollection.Add((SceneNode)sceneElement);
            }
        }
Esempio n. 4
0
 protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
 {
     if (childCollection.Count == selectedChildren.Count)
     {
         return;
     }
     for (int index = 0; index < selectedChildren.Count; ++index)
     {
         SceneElement sceneElement = selectedChildren[index];
         int          num          = childCollection.IndexOf((SceneNode)sceneElement);
         if (num > 0 && !selectedChildren.Contains(childCollection[num - 1] as SceneElement))
         {
             sceneElement.Remove();
             childCollection.Insert(num - 1, (SceneNode)sceneElement);
         }
     }
 }
Esempio n. 5
0
        protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
        {
            if (childCollection.Count == selectedChildren.Count)
            {
                return;
            }
            int num1 = childCollection.Count - 1;

            for (int index = selectedChildren.Count - 1; index >= 0; --index)
            {
                SceneElement sceneElement = selectedChildren[index];
                int          num2         = childCollection.IndexOf((SceneNode)sceneElement);
                if (num2 < num1 && !selectedChildren.Contains(childCollection[num2 + 1] as SceneElement))
                {
                    sceneElement.Remove();
                    childCollection.Insert(num2 + 1, (SceneNode)sceneElement);
                }
            }
        }
        public override void Execute(object arg)
        {
            DesignerContext designerContext      = this.DesignerContext;
            SceneViewModel  activeSceneViewModel = designerContext.ActiveSceneViewModel;
            ITypeId         type = this.Type;

            if (type is ProjectNeutralTypeId)
            {
                bool flag = activeSceneViewModel.ProjectContext.PlatformMetadata.IsSupported((ITypeResolver)this.DesignerContext.ActiveSceneViewModel.ProjectContext, type);
                if (!flag && this.IsDragDropContainer)
                {
                    IMessageDisplayService messageDisplayService = activeSceneViewModel.DesignerContext.MessageDisplayService;
                    flag = ToolkitHelper.EnsureSilverlightToolkitTypeAvailable((ITypeResolver)activeSceneViewModel.ProjectContext, type, messageDisplayService, StringTable.SilverlightToolkitDragDropNotInstalled, StringTable.SilverlightToolkitDragDropIncorrectVersion);
                }
                if (!flag)
                {
                    return;
                }
            }
            using (SceneEditTransaction editTransaction = designerContext.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitGroupIntoLayoutType, new object[1]
            {
                (object)this.Type.Name
            })))
            {
                List <SceneElement> list1    = new List <SceneElement>();
                List <SceneNode>    elements = new List <SceneNode>();
                list1.AddRange((IEnumerable <SceneElement>)designerContext.SelectionManager.ElementSelectionSet.Selection);
                GroupIntoLayoutTypeCommand.OrientationHelper orientationHelper = new GroupIntoLayoutTypeCommand.OrientationHelper();
                list1.Sort((IComparer <SceneElement>) new ZOrderComparer <SceneElement>(this.SceneViewModel.RootNode));
                List <LayoutCacheRecord> list2 = new List <LayoutCacheRecord>(list1.Count);
                Rect empty = Rect.Empty;
                for (int index = 0; index < list1.Count; ++index)
                {
                    list2.Add((LayoutCacheRecord)null);
                    BaseFrameworkElement element = list1[index] as BaseFrameworkElement;
                    if (element != null)
                    {
                        ILayoutDesigner designerForChild   = element.ViewModel.GetLayoutDesignerForChild((SceneElement)element, true);
                        Rect            roundedUpChildRect = LayoutRoundingHelper.GetRoundedUpChildRect(designerForChild, element);
                        empty.Union(roundedUpChildRect);
                        orientationHelper.AddChildRect((SceneNode)element, roundedUpChildRect);
                        LayoutCacheRecord layoutCacheRecord = designerForChild.CacheLayout(element);
                        list2[index] = layoutCacheRecord;
                        elements.Add((SceneNode)element);
                    }
                }
                Dictionary <IPropertyId, SceneNode> properties = (Dictionary <IPropertyId, SceneNode>)null;
                using (this.SceneViewModel.ForceBaseValue())
                {
                    using (this.SceneViewModel.DisableDrawIntoState())
                    {
                        SceneElement sceneElement1 = (SceneElement)null;
                        SceneElement sceneElement2 = (SceneElement)activeSceneViewModel.CreateSceneNode(type);
                        Orientation? nullable      = orientationHelper.ApplyOrientation(sceneElement2);
                        if (nullable.HasValue)
                        {
                            orientationHelper.SortElements(elements, nullable.Value);
                        }
                        int num;
                        if (list1.Count == 1 && list1[0] is BaseFrameworkElement)
                        {
                            int?fixedCapacity = sceneElement2.DefaultContent.FixedCapacity;
                            num = fixedCapacity.GetValueOrDefault() != 1 ? 0 : (fixedCapacity.HasValue ? true : false);
                        }
                        else
                        {
                            num = 0;
                        }
                        bool flag = num != 0;
                        if (sceneElement2 != null)
                        {
                            activeSceneViewModel.GetLayoutDesignerForParent(sceneElement2, true);
                        }
                        foreach (SceneElement sceneElement3 in list1)
                        {
                            if (sceneElement3 != null)
                            {
                                BaseFrameworkElement frameworkElement = sceneElement3 as BaseFrameworkElement;
                                ILayoutDesigner      layoutDesigner   = frameworkElement == null ? (ILayoutDesigner)null : sceneElement3.ViewModel.GetLayoutDesignerForChild((SceneElement)frameworkElement, true);
                                if (flag)
                                {
                                    properties = SceneElementHelper.StoreProperties((SceneNode)sceneElement3, layoutDesigner.GetLayoutProperties(), true);
                                }
                                if (this.SceneViewModel.LockedInsertionPoint != null && this.SceneViewModel.LockedInsertionPoint.SceneElement == sceneElement3)
                                {
                                    sceneElement1 = sceneElement3;
                                }
                            }
                        }
                        if (list1.Count == 1)
                        {
                            VisualStateManagerSceneNode.MoveStates(list1[0], sceneElement2);
                        }
                        using (activeSceneViewModel.DisableUpdateChildrenOnAddAndRemove())
                        {
                            SceneElement primarySelection = designerContext.SelectionManager.ElementSelectionSet.PrimarySelection;
                            designerContext.SelectionManager.ElementSelectionSet.Clear();
                            Dictionary <IPropertyId, List <SceneNode> > storedChildren = new Dictionary <IPropertyId, List <SceneNode> >();
                            storedChildren.Add((IPropertyId)sceneElement2.DefaultContentProperty, elements);
                            ISceneNodeCollection <SceneNode> collectionContainer = primarySelection.GetCollectionContainer();
                            foreach (SceneElement sceneElement3 in list1)
                            {
                                if (sceneElement3 != primarySelection)
                                {
                                    sceneElement3.Remove();
                                }
                            }
                            int index1 = collectionContainer.IndexOf((SceneNode)primarySelection);
                            primarySelection.Remove();
                            collectionContainer.Insert(index1, (SceneNode)sceneElement2);
                            ChangeLayoutTypeCommand.ApplyChildren(sceneElement2, storedChildren, empty.Size);
                            if (flag)
                            {
                                SceneElementHelper.FixElementNameBindingsInStoredProperties((SceneNode)list1[0], (SceneNode)sceneElement2, properties);
                                SceneElementHelper.ApplyProperties((SceneNode)sceneElement2, properties);
                            }
                            else
                            {
                                ILayoutDesigner designerForChild = sceneElement2.ViewModel.GetLayoutDesignerForChild(sceneElement2, true);
                                if (sceneElement2.IsViewObjectValid)
                                {
                                    LayoutOverrides layoutOverrides   = LayoutOverrides.None;
                                    LayoutOverrides overridesToIgnore = LayoutOverrides.None;
                                    if (nullable.HasValue && nullable.Value == Orientation.Horizontal)
                                    {
                                        layoutOverrides |= LayoutOverrides.Width;
                                    }
                                    else
                                    {
                                        overridesToIgnore |= LayoutOverrides.Width;
                                    }
                                    if (nullable.HasValue && nullable.Value == Orientation.Vertical)
                                    {
                                        layoutOverrides |= LayoutOverrides.Height;
                                    }
                                    else
                                    {
                                        overridesToIgnore |= LayoutOverrides.Height;
                                    }
                                    designerForChild.SetChildRect((BaseFrameworkElement)sceneElement2, empty, layoutOverrides, overridesToIgnore, LayoutOverrides.None);
                                }
                            }
                            editTransaction.Update();
                            if (sceneElement2.IsViewObjectValid)
                            {
                                this.SceneViewModel.DefaultView.UpdateLayout();
                                SceneElement    parentElement     = primarySelection.ParentElement;
                                ILayoutDesigner designerForParent = activeSceneViewModel.GetLayoutDesignerForParent(parentElement, true);
                                for (int index2 = 0; index2 < list1.Count; ++index2)
                                {
                                    SceneElement         sceneElement3    = list1[index2];
                                    BaseFrameworkElement frameworkElement = sceneElement3 as BaseFrameworkElement;
                                    if (frameworkElement != null)
                                    {
                                        LayoutCacheRecord layoutCacheRecord = list2[index2];
                                        Rect rect = LayoutRoundingHelper.RoundUpLayoutRect(frameworkElement, layoutCacheRecord.Rect);
                                        rect.Location = (Point)(rect.Location - empty.Location);
                                        designerForParent.ClearUnusedLayoutProperties(frameworkElement);
                                        designerForParent.SetChildRect(frameworkElement, rect, flag ? LayoutOverrides.None : layoutCacheRecord.Overrides, LayoutOverrides.Margin | LayoutOverrides.GridBox, LayoutOverrides.None);
                                        if (this.IsDragDropContainer)
                                        {
                                            sceneElement3.SetValue(Base2DElement.AllowDropProperty, (object)true);
                                        }
                                    }
                                }
                            }
                            if (sceneElement1 != null)
                            {
                                this.SceneViewModel.SetLockedInsertionPoint(sceneElement1);
                            }
                        }
                        designerContext.SelectionManager.ElementSelectionSet.SetSelection(sceneElement2);
                        editTransaction.Commit();
                    }
                }
            }
        }
Esempio n. 7
0
        private SceneElement GroupElements()
        {
            ReadOnlyCollection <SceneElement> selection = this.SceneViewModel.ElementSelectionSet.Selection;

            if (selection[0] is BaseFrameworkElement)
            {
                return((SceneElement)null);
            }
            if (!(selection[0] is Base3DElement))
            {
                return((SceneElement)null);
            }
            SceneElement primarySelection = this.SceneViewModel.ElementSelectionSet.PrimarySelection;

            this.SceneViewModel.ElementSelectionSet.Clear();
            List <SceneElement> list           = new List <SceneElement>((IEnumerable <SceneElement>)selection);
            Base3DElement       base3Delement1 = (Base3DElement)null;
            int num = int.MaxValue;
            Viewport3DElement viewport = ((Base3DElement)list[0]).Viewport;

            foreach (Base3DElement base3Delement2 in list)
            {
                if (base3Delement2.Viewport == viewport)
                {
                    int depthFromViewport3D = base3Delement2.DepthFromViewport3D;
                    if (depthFromViewport3D < num)
                    {
                        base3Delement1 = base3Delement2;
                        num            = depthFromViewport3D;
                    }
                }
            }
            SceneElement parentElement = base3Delement1.ParentElement;
            Matrix3D     matrix3D      = Matrix3D.Identity;

            if (parentElement is Base3DElement)
            {
                matrix3D = ((Base3DElement)parentElement).GetComputedTransformFromViewport3DToElement();
                matrix3D.Invert();
            }
            Base3DElement parent = (Base3DElement)null;

            if (list[0] is Model3DElement)
            {
                Model3DGroup      model3Dgroup      = new Model3DGroup();
                Model3DCollection model3Dcollection = new Model3DCollection();
                model3Dgroup.Children = model3Dcollection;
                parent = (Base3DElement)this.SceneViewModel.CreateSceneNode((object)model3Dgroup);
            }
            else if (list[0] is Visual3DElement)
            {
                parent = (Base3DElement)this.SceneViewModel.CreateSceneNode((object)new ModelVisual3D());
            }
            SceneNodeIDHelper sceneNodeIdHelper = new SceneNodeIDHelper(this.SceneViewModel, (SceneNode)this.SceneViewModel.ActiveSceneInsertionPoint.SceneElement.StoryboardContainer);
            string            validElementId    = sceneNodeIdHelper.GetValidElementID((SceneNode)parent, "group3D");

            sceneNodeIdHelper.SetLocalName((SceneNode)parent, validElementId);
            using (this.SceneViewModel.ForceBaseValue())
            {
                Matrix3D[] matrix3DArray = new Matrix3D[list.Count];
                for (int index = 0; index < list.Count; ++index)
                {
                    matrix3DArray[index] = ((Base3DElement)list[index]).GetComputedTransformFromViewport3DToElement();
                }
                foreach (Base3DElement base3Delement2 in list)
                {
                    if (base3Delement2 != primarySelection)
                    {
                        base3Delement2.Remove();
                    }
                }
                int insertAt = primarySelection.GetCollectionContainer().IndexOf((SceneNode)primarySelection);
                primarySelection.Remove();
                if (parentElement is Viewport3DElement)
                {
                    GroupCommandHelpers.InsertElement(parentElement, (SceneNode)parent, insertAt);
                }
                else
                {
                    GroupCommandHelpers.InsertElement(this.SceneViewModel, (Base3DElement)parentElement, (SceneNode)parent, new int?(insertAt));
                }
                for (int index = 0; index < list.Count; ++index)
                {
                    GroupCommandHelpers.InsertElement(this.SceneViewModel, parent, (SceneNode)list[index], new int?());
                    ((Base3DElement)list[index]).Transform = (Transform3D) new CanonicalTransform3D(matrix3DArray[index] * matrix3D);
                }
            }
            return((SceneElement)parent);
        }
        public override void Execute()
        {
            string               fileName           = "test";
            IProject             activeProject      = this.DesignerContext.ActiveProject;
            TemplateItemHelper   templateItemHelper = new TemplateItemHelper(activeProject, (IList <string>)null, (IServiceProvider)this.DesignerContext.Services);
            IProjectItemTemplate templateItem       = templateItemHelper.FindTemplateItem("UserControl");

            if (templateItem == null)
            {
                this.DesignerContext.MessageDisplayService.ShowError(StringTable.MakeUserControlTemplateNotFound);
            }
            else
            {
                SceneViewModel      activeSceneViewModel = this.DesignerContext.ActiveSceneViewModel;
                List <SceneElement> elements             = new List <SceneElement>();
                elements.AddRange((IEnumerable <SceneElement>)activeSceneViewModel.ElementSelectionSet.Selection);
                elements.Sort((IComparer <SceneElement>) new ZOrderComparer <SceneElement>(activeSceneViewModel.RootNode));
                if (this.ShowUI)
                {
                    string recommendedName = this.GetRecommendedName((IEnumerable <SceneElement>)elements);
                    MakeUserControlDialog userControlDialog = new MakeUserControlDialog(this.DesignerContext, this.DialogTitle, templateItemHelper, recommendedName);
                    bool?nullable = userControlDialog.ShowDialog();
                    if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0)
                    {
                        return;
                    }
                    fileName = userControlDialog.ControlName;
                }
                List <IProjectItem>        itemsToOpen  = (List <IProjectItem>)null;
                IProjectItem               projectItem1 = (IProjectItem)null;
                IEnumerable <IProjectItem> source       = (IEnumerable <IProjectItem>)null;
                try
                {
                    source = templateItemHelper.AddProjectItemsForTemplateItem(templateItem, fileName, this.DesignerContext.ProjectManager.TargetFolderForProject(activeProject), CreationOptions.DoNotAllowOverwrites | CreationOptions.DoNotSelectCreatedItems | CreationOptions.DoNotSetDefaultImportPath, out itemsToOpen);
                }
                catch (Exception ex)
                {
                    if (ex is NotSupportedException || ErrorHandling.ShouldHandleExceptions(ex))
                    {
                        this.DesignerContext.MessageDisplayService.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ProjectNewFileErrorDialogMessage, new object[2]
                        {
                            (object)fileName,
                            (object)ex.Message
                        }));
                    }
                    else
                    {
                        throw;
                    }
                }
                if (source == null || EnumerableExtensions.CountIsLessThan <IProjectItem>(source, 1))
                {
                    return;
                }
                if (itemsToOpen != null && itemsToOpen.Count > 0)
                {
                    projectItem1 = Enumerable.FirstOrDefault <IProjectItem>((IEnumerable <IProjectItem>)itemsToOpen);
                    projectItem1.OpenDocument(false, true);
                }
                if (projectItem1 != null && projectItem1.IsOpen && projectItem1.DocumentType.CanView)
                {
                    Rect empty = Rect.Empty;
                    for (int index = 0; index < elements.Count; ++index)
                    {
                        BaseFrameworkElement child = elements[index] as BaseFrameworkElement;
                        if (child != null)
                        {
                            Rect childRect = child.ViewModel.GetLayoutDesignerForChild((SceneElement)child, true).GetChildRect(child);
                            empty.Union(childRect);
                        }
                    }
                    Rect         rect              = RoundingHelper.RoundRect(empty);
                    SceneElement parentElement     = elements[0].ParentElement;
                    bool         useLayoutRounding = LayoutRoundingHelper.GetUseLayoutRounding(parentElement);
                    DataObject   dataObject        = (DataObject)null;
                    using (activeSceneViewModel.ForceBaseValue())
                    {
                        PastePackage pastePackage = new PastePackage(activeSceneViewModel);
                        pastePackage.CopyStoryboardsReferencingElements = true;
                        pastePackage.AddElements(elements);
                        dataObject = pastePackage.GetPasteDataObject();
                    }
                    SceneView sceneView = projectItem1.OpenView(true) as SceneView;
                    if (sceneView != null)
                    {
                        SceneViewModel     viewModel           = sceneView.ViewModel;
                        ProjectXamlContext projectXamlContext  = ProjectXamlContext.FromProjectContext(viewModel.ViewRoot.ProjectContext);
                        ClassAttributes    rootClassAttributes = viewModel.DocumentRoot.RootClassAttributes;
                        ITypeId            typeId = (ITypeId)null;
                        if (projectXamlContext != null && rootClassAttributes != null)
                        {
                            projectXamlContext.RefreshUnbuiltTypeDescriptions();
                            if (rootClassAttributes != null)
                            {
                                typeId = (ITypeId)projectXamlContext.GetType(projectXamlContext.ProjectAssembly.Name, rootClassAttributes.QualifiedClassName);
                            }
                        }
                        if (typeId != null && this.CheckForCircularReference((IEnumerable <SceneElement>)elements, typeId))
                        {
                            this.DesignerContext.MessageDisplayService.ShowError(StringTable.MakeUserControlCircularReferenceFound);
                            this.CleanupAfterCancel(projectItem1);
                            return;
                        }
                        using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoUnitMakeUserControl))
                        {
                            if (!rect.IsEmpty)
                            {
                                viewModel.RootNode.SetValue(DesignTimeProperties.DesignWidthProperty, (object)rect.Width);
                                viewModel.RootNode.SetValue(DesignTimeProperties.DesignHeightProperty, (object)rect.Height);
                                if (this.AddToApplicationFlow)
                                {
                                    viewModel.RootNode.SetValue(BaseFrameworkElement.WidthProperty, (object)rect.Width);
                                    viewModel.RootNode.SetValue(BaseFrameworkElement.HeightProperty, (object)rect.Height);
                                }
                            }
                            IProperty property = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty(viewModel.RootNode);
                            if (property != null)
                            {
                                viewModel.RootNode.SetValue((IPropertyId)property, (object)(bool)(useLayoutRounding ? true : false));
                            }
                            ILayoutDesigner         designerForParent = viewModel.GetLayoutDesignerForParent(viewModel.ActiveSceneInsertionPoint.SceneElement, true);
                            bool                    canceledPasteOperation;
                            ICollection <SceneNode> nodes = PasteCommand.PasteData(viewModel, new SafeDataObject((IDataObject)dataObject), viewModel.ActiveSceneInsertionPoint, out canceledPasteOperation);
                            if (canceledPasteOperation)
                            {
                                editTransaction.Cancel();
                                this.CleanupAfterCancel(projectItem1);
                                return;
                            }
                            editTransaction.Update();
                            if (nodes.Count > 0)
                            {
                                viewModel.DefaultView.UpdateLayout();
                                viewModel.SelectNodes(nodes);
                                if (designerForParent != null)
                                {
                                    foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)nodes)
                                    {
                                        BaseFrameworkElement child = sceneNode as BaseFrameworkElement;
                                        if (child != null && child.IsViewObjectValid)
                                        {
                                            Rect childRect = child.ViewModel.GetLayoutDesignerForChild((SceneElement)child, true).GetChildRect(child);
                                            childRect.Location = (Point)(childRect.Location - rect.Location);
                                            designerForParent.SetChildRect(child, childRect);
                                        }
                                    }
                                }
                            }
                            editTransaction.Commit();
                        }
                        if (this.AddToApplicationFlow && this.DesignerContext.PrototypingService != null)
                        {
                            this.DesignerContext.PrototypingService.PromoteToCompositionScreen(projectItem1);
                        }
                        if (typeId != null)
                        {
                            using (activeSceneViewModel.ForceBaseValue())
                            {
                                using (activeSceneViewModel.DisableDrawIntoState())
                                {
                                    using (SceneEditTransaction editTransaction = activeSceneViewModel.CreateEditTransaction(StringTable.UndoUnitMakeUserControl))
                                    {
                                        using (activeSceneViewModel.DisableUpdateChildrenOnAddAndRemove())
                                        {
                                            SceneElement primarySelection = activeSceneViewModel.ElementSelectionSet.PrimarySelection;
                                            IProperty    propertyForChild = parentElement.GetPropertyForChild((SceneNode)primarySelection);
                                            PropertySceneInsertionPoint sceneInsertionPoint = new PropertySceneInsertionPoint(parentElement, propertyForChild);
                                            SceneNode sceneNode = (SceneNode)null;
                                            if (sceneInsertionPoint.CanInsert(typeId))
                                            {
                                                foreach (SceneElement element in elements)
                                                {
                                                    if (element != primarySelection)
                                                    {
                                                        activeSceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
                                                        element.Remove();
                                                    }
                                                }
                                                ISceneNodeCollection <SceneNode> collectionForProperty = parentElement.GetCollectionForProperty((IPropertyId)propertyForChild);
                                                int index = collectionForProperty.IndexOf((SceneNode)primarySelection);
                                                activeSceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(primarySelection);
                                                primarySelection.Remove();
                                                sceneNode = activeSceneViewModel.CreateSceneNode(typeId);
                                                collectionForProperty.Insert(index, sceneNode);
                                                this.DesignerContext.ViewService.ActiveView = (IView)activeSceneViewModel.DefaultView;
                                                editTransaction.Update();
                                                activeSceneViewModel.DefaultView.UpdateLayout();
                                                BaseFrameworkElement child = sceneNode as BaseFrameworkElement;
                                                if (child != null && child.IsViewObjectValid)
                                                {
                                                    activeSceneViewModel.GetLayoutDesignerForParent(parentElement, true).SetChildRect(child, rect);
                                                }
                                            }
                                            if (this.AddToApplicationFlow)
                                            {
                                                if (sceneNode != null)
                                                {
                                                    sceneNode.SetValue(DesignTimeProperties.IsPrototypingCompositionProperty, (object)true);
                                                }
                                            }
                                        }
                                        editTransaction.Commit();
                                    }
                                }
                            }
                            this.DesignerContext.ViewService.ActiveView = (IView)viewModel.DefaultView;
                        }
                    }
                }
                if (itemsToOpen == null || itemsToOpen.Count <= 1)
                {
                    return;
                }
                foreach (IProjectItem projectItem2 in itemsToOpen)
                {
                    if (projectItem1 != projectItem2)
                    {
                        projectItem2.OpenView(true);
                    }
                }
            }
        }