Ejemplo n.º 1
0
        private static Dictionary <IPropertyId, List <SceneNode> > StoreChildren(SceneElement sourceElement)
        {
            Dictionary <IPropertyId, List <SceneNode> > dictionary = new Dictionary <IPropertyId, List <SceneNode> >();

            foreach (IPropertyId propertyId in sourceElement.ContentProperties)
            {
                ISceneNodeCollection <SceneNode> collectionForProperty = sourceElement.GetCollectionForProperty(propertyId);
                if (collectionForProperty != null)
                {
                    while (collectionForProperty.Count > 0)
                    {
                        SceneNode sceneNode = collectionForProperty[0];
                        if (sceneNode.DocumentNode != null)
                        {
                            DocumentNodeHelper.PreserveFormatting(sceneNode.DocumentNode);
                        }
                        sceneNode.Remove();
                        List <SceneNode> list = (List <SceneNode>)null;
                        if (!dictionary.TryGetValue(propertyId, out list))
                        {
                            list = new List <SceneNode>();
                            dictionary.Add(propertyId, list);
                        }
                        list.Add(sceneNode);
                    }
                }
            }
            return(dictionary);
        }
Ejemplo n.º 2
0
        public static void MoveStates(SceneElement source, SceneElement target)
        {
            if (source == null || target == null || source.ProjectContext.PlatformMetadata.IsNullType((ITypeId)source.ProjectContext.ResolveType(ProjectNeutralTypes.VisualStateManager)))
            {
                return;
            }
            IList <VisualStateGroupSceneNode> stateGroups = VisualStateManagerSceneNode.GetStateGroups((SceneNode)target);

            stateGroups.Clear();
            ISceneNodeCollection <SceneNode> collectionForProperty = source.GetCollectionForProperty(VisualStateManagerSceneNode.VisualStateGroupsProperty);
            List <VisualStateGroupSceneNode> list = new List <VisualStateGroupSceneNode>();

            foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)collectionForProperty)
            {
                if (sceneNode is VisualStateGroupSceneNode)
                {
                    list.Add((VisualStateGroupSceneNode)VisualStateGroupSceneNode.Factory.Instantiate(target.ViewModel, sceneNode.DocumentNode.Clone(target.DocumentContext)));
                }
            }
            collectionForProperty.Clear();
            foreach (VisualStateGroupSceneNode stateGroupSceneNode in list)
            {
                stateGroups.Add(stateGroupSceneNode);
            }
        }
Ejemplo n.º 3
0
 internal static int GetMaxChildrenForElement(SceneElement element, IProperty property = null)
 {
     if (property == null)
     {
         property = element.DefaultContentProperty;
     }
     if (!element.IsContainer && property == element.DefaultContentProperty)
     {
         return(0);
     }
     return(element.GetCollectionForProperty((IPropertyId)property).FixedCapacity ?? int.MaxValue);
 }
Ejemplo n.º 4
0
        private void SetCameraTypeOnSelection(Type cameraType)
        {
            if (this.selectedCameras.Count == 0 || this.cameraType.Equals((object)cameraType))
            {
                return;
            }
            this.cameraType = (object)cameraType;
            SceneViewModel           viewModel           = this.selectedCameras[0].ViewModel;
            SceneElementSelectionSet elementSelectionSet = viewModel.ElementSelectionSet;

            using (SceneEditTransaction editTransaction = viewModel.Document.CreateEditTransaction(StringTable.UndoUnitChangeCameraType))
            {
                foreach (ProjectionCameraElement projectionCameraElement1 in this.selectedCameras)
                {
                    if (!(projectionCameraElement1.TargetType == cameraType))
                    {
                        ProjectionCameraElement projectionCameraElement2;
                        if (typeof(OrthographicCamera).IsAssignableFrom(cameraType))
                        {
                            projectionCameraElement2 = (ProjectionCameraElement)OrthographicCameraElement.Factory.Instantiate(projectionCameraElement1.ViewModel);
                            projectionCameraElement2.SetValue(OrthographicCameraElement.WidthProperty, (object)10.0);
                        }
                        else if (typeof(PerspectiveCamera).IsAssignableFrom(cameraType))
                        {
                            projectionCameraElement2 = (ProjectionCameraElement)PerspectiveCameraElement.Factory.Instantiate(projectionCameraElement1.ViewModel);
                            projectionCameraElement2.SetValue(PerspectiveCameraElement.FieldOfViewProperty, (object)45.0);
                        }
                        else
                        {
                            continue;
                        }
                        projectionCameraElement1.ViewModel.AnimationEditor.DeleteAllAnimations((SceneNode)projectionCameraElement1);
                        Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)projectionCameraElement1);
                        elementSelectionSet.RemoveSelection((SceneElement)projectionCameraElement1);
                        SceneElement parentElement = projectionCameraElement1.ParentElement;
                        ISceneNodeCollection <SceneNode> collectionForProperty = parentElement.GetCollectionForProperty((IPropertyId)parentElement.GetPropertyForChild((SceneNode)projectionCameraElement1));
                        int index = collectionForProperty.IndexOf((SceneNode)projectionCameraElement1);
                        collectionForProperty[index] = (SceneNode)projectionCameraElement2;
                        SceneElementHelper.ApplyProperties((SceneNode)projectionCameraElement2, properties);
                        elementSelectionSet.ExtendSelection((SceneElement)projectionCameraElement2);
                    }
                }
                editTransaction.Commit();
            }
            this.OnPropertyChanged("IsCameraOrthographic");
            this.OnPropertyChanged("IsCameraPerspective");
        }
        protected SceneElement GetDropTargetInfo(TimelineDropEffects dropEffects, TimelineDragDescriptor descriptor)
        {
            SceneElement sceneElement1 = this.Element;

            if (sceneElement1 == null)
            {
                return((SceneElement)null);
            }
            descriptor.DropIndex = -1;
            int          num           = 0;
            SceneElement sceneElement2 = (SceneElement)null;
            bool         flag          = false;

            if ((dropEffects & TimelineDropEffects.Before) != TimelineDropEffects.None)
            {
                sceneElement1 = this.Element.VisualElementAncestor;
                sceneElement2 = this.Element.VisualElementAncestor;
                if (this.Item.IsExpanded && this.Item.HasActiveChild)
                {
                    sceneElement1            = this.Element;
                    sceneElement2            = this.Element;
                    descriptor.RelativeDepth = 1;
                }
                num  = 1;
                flag = true;
            }
            else if ((dropEffects & TimelineDropEffects.After) != TimelineDropEffects.None)
            {
                sceneElement1 = this.Element.VisualElementAncestor;
                sceneElement2 = this.Element.VisualElementAncestor;
                flag          = true;
            }
            if (flag && sceneElement2 != null)
            {
                ISceneNodeCollection <SceneNode> collectionForProperty = sceneElement2.GetCollectionForProperty((IPropertyId)this.GetContentPropertyFromDragDescriptor(descriptor));
                if (collectionForProperty != null)
                {
                    descriptor.DropIndex = collectionForProperty.IndexOf((SceneNode)this.Element) + num;
                }
            }
            if (!this.Element.ViewModel.ActiveEditingContainer.IsAncestorOf((SceneNode)sceneElement1))
            {
                sceneElement1 = (SceneElement)null;
            }
            return(sceneElement1);
        }
Ejemplo n.º 6
0
 private static bool CanAddMultipleElements(SceneElement pasteRoot, int elementCount)
 {
     if (pasteRoot is StyleNode && elementCount > 1)
     {
         return(false);
     }
     if (elementCount > 1)
     {
         IPropertyId childProperty = (IPropertyId)pasteRoot.DefaultContentProperty;
         ISceneNodeCollection <SceneNode> collectionForProperty = pasteRoot.GetCollectionForProperty(childProperty);
         if (collectionForProperty.FixedCapacity.HasValue && elementCount > collectionForProperty.FixedCapacity.Value - collectionForProperty.Count)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 7
0
        internal static SceneElement ApplyChildren(SceneElement destinationElement, Dictionary <IPropertyId, List <SceneNode> > storedChildren, Size size)
        {
            SceneElement sceneElement = (SceneElement)null;

            foreach (KeyValuePair <IPropertyId, List <SceneNode> > keyValuePair in storedChildren)
            {
                IPropertyId   childProperty = keyValuePair.Key;
                ReferenceStep referenceStep = childProperty as ReferenceStep;
                if (referenceStep != null)
                {
                    childProperty = (IPropertyId)SceneNodeObjectSet.FilterProperty((SceneNode)destinationElement, referenceStep) ?? (IPropertyId)destinationElement.DefaultContentProperty;
                }
                if (childProperty != null)
                {
                    ISceneNodeCollection <SceneNode> collectionForProperty = destinationElement.GetCollectionForProperty(childProperty);
                    if (collectionForProperty != null)
                    {
                        sceneElement = destinationElement;
                        List <SceneNode> list = keyValuePair.Value;
                        if (collectionForProperty.FixedCapacity.HasValue && list.Count > collectionForProperty.FixedCapacity.Value - collectionForProperty.Count)
                        {
                            SceneNode sceneNode = destinationElement.ViewModel.CreateSceneNode(PlatformTypes.Grid);
                            if (ProjectNeutralTypes.Viewbox.IsAssignableFrom((ITypeId)destinationElement.Type) && !size.IsEmpty)
                            {
                                sceneNode.SetValue(BaseFrameworkElement.WidthProperty, (object)size.Width);
                                sceneNode.SetValue(BaseFrameworkElement.HeightProperty, (object)size.Height);
                            }
                            collectionForProperty.Add(sceneNode);
                            collectionForProperty = sceneNode.GetCollectionForProperty((IPropertyId)sceneNode.DefaultContentProperty);
                            sceneElement          = sceneNode as SceneElement;
                        }
                        if (ProjectNeutralTypes.Viewbox.IsAssignableFrom((ITypeId)destinationElement.Type))
                        {
                            destinationElement.SetValue(ViewboxElement.StretchProperty, (object)Stretch.Fill);
                        }
                        foreach (SceneNode sceneNode in list)
                        {
                            collectionForProperty.Add(sceneNode);
                        }
                    }
                }
            }
            return(sceneElement);
        }
Ejemplo n.º 8
0
        public static void ClearMutuallyExclusivePropertyIfNeeded(SceneElement itemsControl, PropertyReference propertyReference)
        {
            ReferenceStep firstStep = propertyReference.FirstStep;

            if (ItemsControlElement.ItemsSourceProperty.Equals((object)firstStep))
            {
                ISceneNodeCollection <SceneNode> collectionForProperty = itemsControl.GetCollectionForProperty((IPropertyId)itemsControl.DefaultContentProperty);
                if (collectionForProperty != null)
                {
                    foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)collectionForProperty)
                    {
                        SceneElement element = sceneNode as SceneElement;
                        if (element != null)
                        {
                            itemsControl.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
                        }
                    }
                    collectionForProperty.Clear();
                }
                itemsControl.ClearValue(ItemsControlElement.ItemsProperty);
            }
            else if (ItemsControlElement.ItemsProperty.Equals((object)firstStep))
            {
                ItemsControlElement.UpdateItemsSourceOnItemsChanged(itemsControl);
            }
            else if (ItemsControlElement.ItemTemplateProperty.Equals((object)firstStep))
            {
                itemsControl.ClearValue(ItemsControlElement.DisplayMemberPathProperty);
            }
            else
            {
                if (!ItemsControlElement.DisplayMemberPathProperty.Equals((object)firstStep))
                {
                    return;
                }
                itemsControl.ClearValue(ItemsControlElement.ItemTemplateProperty);
            }
        }
Ejemplo n.º 9
0
 public IEnumerable <AnnotationSceneNode> GetAttachedAnnotations(SceneElement element)
 {
     ExceptionChecks.CheckNullArgument <SceneElement>(element, "element");
     if (element == element.ViewModel.RootNode)
     {
         return(Enumerable.Empty <AnnotationSceneNode>());
     }
     return(Enumerable.Union <AnnotationSceneNode>(Enumerable.Cast <AnnotationSceneNode>((IEnumerable)element.GetCollectionForProperty(AnnotationManagerSceneNode.AnnotationsProperty)), this.GetReferencedAnnotations(element)));
 }
Ejemplo n.º 10
0
        private void SetLightTypeOnSelection(Type lightType)
        {
            if (this.selectedLights.Count == 0 || this.lightType != null && this.lightType.Equals((object)lightType))
            {
                return;
            }
            this.lightType = (object)lightType;
            SceneViewModel           viewModel                     = this.selectedLights[0].ViewModel;
            SceneElementSelectionSet elementSelectionSet           = viewModel.ElementSelectionSet;
            List <KeyValuePair <LightElement, LightElement> > list = new List <KeyValuePair <LightElement, LightElement> >();

            foreach (LightElement key in (IEnumerable <LightElement>)elementSelectionSet.GetFilteredSelection <LightElement>())
            {
                if (!(key.TargetType == lightType))
                {
                    LightElement lightElement = (LightElement)key.ViewModel.CreateSceneNode(lightType);
                    DocumentNode documentNode = (DocumentNode)null;
                    if (typeof(SpotLight).Equals(lightType))
                    {
                        DocumentNodePath valueAsDocumentNode = key.GetLocalValueAsDocumentNode(SpotLightElement.DirectionProperty);
                        documentNode = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null;
                    }
                    else if (typeof(DirectionalLight).Equals(lightType))
                    {
                        DocumentNodePath valueAsDocumentNode = key.GetLocalValueAsDocumentNode(DirectionalLightElement.DirectionProperty);
                        documentNode = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null;
                    }
                    if (typeof(DirectionalLight).Equals(lightType))
                    {
                        if (documentNode != null)
                        {
                            lightElement.SetValue(DirectionalLightElement.DirectionProperty, (object)documentNode);
                        }
                    }
                    else if (typeof(PointLightBase).IsAssignableFrom(lightType))
                    {
                        if (!typeof(PointLightBase).IsAssignableFrom(key.TargetType))
                        {
                            lightElement.SetValue(LightElement.PositionProperty, (object)new Point3D(0.0, 0.0, 0.0));
                            lightElement.SetValue(LightElement.RangeProperty, (object)10.0);
                            lightElement.SetValue(LightElement.ConstantAttenuationProperty, (object)1.0);
                            lightElement.SetValue(LightElement.LinearAttenuationProperty, (object)0.0);
                            lightElement.SetValue(LightElement.QuadraticAttenuationProperty, (object)0.0);
                        }
                        if (typeof(SpotLight).Equals(lightType))
                        {
                            if (documentNode != null)
                            {
                                lightElement.SetValue(SpotLightElement.DirectionProperty, (object)documentNode);
                            }
                            lightElement.SetValue(SpotLightElement.OuterConeAngleProperty, (object)40.0);
                            lightElement.SetValue(SpotLightElement.InnerConeAngleProperty, (object)30.0);
                        }
                    }
                    list.Add(new KeyValuePair <LightElement, LightElement>(key, lightElement));
                }
            }
            if (list.Count != 0)
            {
                using (SceneEditTransaction editTransaction = viewModel.Document.CreateEditTransaction(StringTable.UndoUnitChangeLightType))
                {
                    foreach (KeyValuePair <LightElement, LightElement> keyValuePair in list)
                    {
                        LightElement key          = keyValuePair.Key;
                        LightElement lightElement = keyValuePair.Value;
                        viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)key);
                        Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)key);
                        elementSelectionSet.RemoveSelection((SceneElement)key);
                        SceneElement parentElement = key.ParentElement;
                        ISceneNodeCollection <SceneNode> collectionForProperty = parentElement.GetCollectionForProperty((IPropertyId)parentElement.GetPropertyForChild((SceneNode)key));
                        int index = collectionForProperty.IndexOf((SceneNode)key);
                        collectionForProperty[index] = (SceneNode)lightElement;
                        SceneElementHelper.ApplyProperties((SceneNode)lightElement, properties);
                        elementSelectionSet.ExtendSelection((SceneElement)lightElement);
                    }
                    editTransaction.Commit();
                }
            }
            this.OnPropertyChanged("IsAmbientLight");
            this.OnPropertyChanged("IsPointLight");
            this.OnPropertyChanged("IsDirectionalLight");
            this.OnPropertyChanged("IsSpotLight");
        }
        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);
                    }
                }
            }
        }