예제 #1
0
 public override void Execute()
 {
     PerformanceUtility.StartPerformanceSequence(PerformanceEvent.Make3D);
     try
     {
         using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
         {
             BaseFrameworkElement frameworkElement = (BaseFrameworkElement)this.SceneViewModel.ElementSelectionSet.PrimarySelection;
             using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoUnitName, false))
             {
                 ILayoutDesigner designerForChild = this.SceneViewModel.GetLayoutDesignerForChild((SceneElement)frameworkElement, true);
                 Rect            childRect        = designerForChild.GetChildRect(frameworkElement);
                 DocumentNode    newValue         = this.CreateValue(frameworkElement);
                 if (newValue == null)
                 {
                     editTransaction.Cancel();
                 }
                 else if (this.CreateResource && this.ProcessAsResource(frameworkElement, newValue) == null)
                 {
                     editTransaction.Cancel();
                 }
                 else
                 {
                     if (this.ShouldReplaceOriginal)
                     {
                         this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)frameworkElement);
                         Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)frameworkElement, true);
                         this.SceneViewModel.ElementSelectionSet.Clear();
                         BaseFrameworkElement element = this.CreateElement(frameworkElement);
                         using (this.SceneViewModel.ForceBaseValue())
                         {
                             element.Name = frameworkElement.Name;
                             ISceneNodeCollection <SceneNode> collectionForChild = frameworkElement.ParentElement.GetCollectionForChild((SceneNode)frameworkElement);
                             int index = collectionForChild.IndexOf((SceneNode)frameworkElement);
                             frameworkElement.Remove();
                             this.Postprocess(frameworkElement, element, properties, childRect);
                             collectionForChild.Insert(index, (SceneNode)element);
                             SceneElementHelper.ApplyProperties((SceneNode)element, properties);
                             editTransaction.Update();
                             designerForChild.SetChildRect(element, childRect);
                         }
                         this.SceneViewModel.ElementSelectionSet.SetSelection((SceneElement)element);
                     }
                     editTransaction.Commit();
                 }
             }
         }
     }
     finally
     {
         PerformanceUtility.EndPerformanceSequence(PerformanceEvent.Make3D);
     }
 }
예제 #2
0
        private void ChangeFontReference(FontChangeType fontChange, IProjectFont projectFont)
        {
            FontFamily oldFontFamily;
            FontFamily newFontFamily;

            FontEmbedder.CreateFontFamilyChange(fontChange, projectFont, this.viewModel.Document.DocumentContext, out oldFontFamily, out newFontFamily);
            if (!(oldFontFamily.Source != newFontFamily.Source))
            {
                return;
            }
            SceneElement sceneElement = this.viewModel.RootNode as SceneElement;

            if (sceneElement == null)
            {
                return;
            }
            FontFamilyRepairProcessor familyRepairProcessor = new FontFamilyRepairProcessor(this.viewModel.DesignerContext, new FontFamilyChangeModel(oldFontFamily.Source, newFontFamily.Source, fontChange, projectFont, sceneElement.DocumentNode.DocumentRoot, this.viewModel.ProjectContext));

            using (SceneEditTransaction editTransaction = this.viewModel.CreateEditTransaction(StringTable.EmbedFontUndoUnit))
            {
                familyRepairProcessor.Begin();
                if (familyRepairProcessor.Cancelled)
                {
                    editTransaction.Cancel();
                }
                else
                {
                    editTransaction.Commit();
                }
            }
        }
예제 #3
0
        protected override DragDropEffects OnHandleDrop(DragDropEffects dropEffects)
        {
            bool flag = (dropEffects & DragDropEffects.Copy) != DragDropEffects.None;

            using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(flag ? StringTable.UndoUnitCopy : StringTable.UndoUnitArrange))
            {
                this.ViewModel.ClearSelections();
                SceneNode sceneNode = !flag?this.Move((SceneNode)this.SourceData) : this.Copy((SceneNode)this.SourceData);

                if (sceneNode != null)
                {
                    this.ViewModel.SelectNodes((ICollection <SceneNode>) new SceneNode[1]
                    {
                        sceneNode
                    });
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                    return(DragDropEffects.None);
                }
            }
            return(dropEffects);
        }
예제 #4
0
        private bool SetBindingOnExistingElement()
        {
            bool flag = false;

            using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitDragDropCreateDataboundControl))
            {
                if (DataBindingModeModel.Instance.NormalizedMode == DataBindingMode.Details)
                {
                    this.GetReusableDetailsContainer(true, this.DragModel.CheckDropFlags(DataBindingDragDropFlags.SetBinding));
                }
                IProperty targetProperty = this.DragModel.TargetProperty;
                if (this.SetBinding(this.DragModel.TargetNode, ref targetProperty))
                {
                    if (DataBindingModeModel.Instance.NormalizedMode == DataBindingMode.Details && this.DragModel.InsertionPoint.SceneElement != null && DesignTimeProperties.DesignDataContextProperty.Equals((object)targetProperty))
                    {
                        DocumentCompositeNode documentCompositeNode = this.DragModel.TargetNode.DocumentNode as DocumentCompositeNode;
                        if (documentCompositeNode != null && documentCompositeNode.Properties[BaseFrameworkElement.DataContextProperty] == null)
                        {
                            this.LinkDetailsWithMasterControl(this.DragModel.InsertionPoint.SceneElement);
                        }
                    }
                    editTransaction.Commit();
                    this.DragModel.OnUserSelectedProperty(targetProperty);
                    flag = true;
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
            return(flag);
        }
예제 #5
0
 private static void ForceClearPropertyInspector(IPropertyId resolvedProperty, SceneElement element)
 {
     using (element.ViewModel.ForceBaseValue())
     {
         SceneEditTransaction editTransaction = element.DesignerContext.ActiveDocument.CreateEditTransaction("Hidden", true);
         using (editTransaction)
         {
             element.SetValue(resolvedProperty, (object)true);
             editTransaction.Cancel();
         }
     }
 }
        public void SelectElement(SceneElement element, SceneNodeProperty editingProperty)
        {
            ISchema schemaForDataSource = SchemaManager.GetSchemaForDataSource((SceneNode)element);

            using (SceneEditTransaction editTransaction = element.ViewModel.CreateEditTransaction(StringTable.CreateElementPropertyBindingUndo))
            {
                BindingSceneNode elementNameBinding = MiniBindingDialog.CreateElementNameBinding(new DataSchemaNodePath(schemaForDataSource, schemaForDataSource.Root), (SceneNode)element, editingProperty.PropertyTypeId);
                if (elementNameBinding != null)
                {
                    editingProperty.SetValue((object)elementNameBinding.DocumentNode);
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }
        public void ConvertSelection(KeyFrameInterpolationType keyframeInterpolationType)
        {
            SceneNode sceneNode = this.selectedObjects[0];

            if (sceneNode.ViewModel == null)
            {
                return;
            }
            SceneViewModel viewModel = sceneNode.ViewModel;

            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.ConvertKeyFramesUndoUnit, false))
            {
                bool flag = false;
                foreach (object obj in this.selectedObjects)
                {
                    KeyFrameSceneNode keyFrame = obj as KeyFrameSceneNode;
                    if (keyFrame == null || keyFrame.KeyFrameAnimation == null)
                    {
                        flag = false;
                        break;
                    }
                    if (keyFrame.InterpolationType != keyframeInterpolationType)
                    {
                        KeyFrameSceneNode selectionToExtend = keyFrame.KeyFrameAnimation.ReplaceKeyFrame(keyFrame, keyframeInterpolationType, (KeySpline)null);
                        if (selectionToExtend == null)
                        {
                            flag = false;
                            break;
                        }
                        viewModel.KeyFrameSelectionSet.ExtendSelection(selectionToExtend);
                        flag = true;
                    }
                }
                if (flag)
                {
                    editTransaction.Commit();
                    viewModel.RefreshSelection();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }
예제 #8
0
        public override void RefreshAllInstances(DocumentReference documentReference, IDocument document)
        {
            SceneDocument sceneDocument = document as SceneDocument;

            if (sceneDocument == null)
            {
                return;
            }
            SceneViewModel sceneViewModel = this.GetSceneViewModel(sceneDocument);

            if (sceneViewModel == null)
            {
                return;
            }
            bool         flag        = false;
            SceneElement rootElement = sceneViewModel.RootNode as SceneElement;

            if (rootElement == null)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = sceneDocument.CreateEditTransaction(StringTable.AssetFileUpdatedUndo, true))
            {
                foreach (SceneElement element in SceneElementHelper.GetLogicalTree(rootElement))
                {
                    if (this.DoesNodeReferenceUrl(element.DocumentNode, documentReference.Path))
                    {
                        this.RefreshInstance(element, sceneDocument, documentReference.Path);
                        flag = true;
                    }
                }
                if (flag)
                {
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }
예제 #9
0
        private void OnOpenDialogWindow(object sender, ExecutedRoutedEventArgs eventArgs)
        {
            PropertyReferenceProperty referenceProperty = (PropertyReferenceProperty)PropertyEditingHelper.GetEditedProperty(eventArgs.OriginalSource, eventArgs.Parameter);
            DataTemplate dialogEditorTemplate           = PropertyEditingHelper.GetDialogEditorTemplate((PropertyEntry)referenceProperty);

            if (dialogEditorTemplate == null)
            {
                return;
            }
            Dialog dialog    = (Dialog) new DialogValueEditorHost(referenceProperty.get_PropertyValue(), dialogEditorTemplate);
            int    remaining = 0;
            SceneEditTransaction sceneEditTransaction = (SceneEditTransaction)null;

            if (this.ActiveDocument != null)
            {
                this.CommitOutstandingTransactions(0);
                sceneEditTransaction = this.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.DialogValueEditorUndoDescription, new object[1]
                {
                    (object)referenceProperty.get_DisplayName()
                }));
                this.editTransactions.Push(sceneEditTransaction);
                remaining = this.editTransactions.Count;
            }
            bool?nullable = dialog.ShowDialog();

            if (this.ActiveDocument != null)
            {
                this.CommitOutstandingTransactions(remaining);
                if (nullable.HasValue && nullable.Value)
                {
                    sceneEditTransaction.Commit();
                }
                else
                {
                    sceneEditTransaction.Cancel();
                }
                this.editTransactions.Pop();
            }
            eventArgs.Handled = true;
        }
예제 #10
0
        private bool CreateItemsControl(Point dropPoint)
        {
            if (this.DragModel.NewElementType == DataBindingDragDropDefaultHandler.TreeControlType && !this.EnsureTreeControlTypeAssembly())
            {
                return(false);
            }
            BaseFrameworkElement child1 = (BaseFrameworkElement)null;

            using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitDragDropCreateDataboundControl))
            {
                Rect rect = new Rect(dropPoint, new Point(double.PositiveInfinity, double.PositiveInfinity));
                child1 = (BaseFrameworkElement) new UserThemeTypeInstantiator(this.DragModel.ViewModel.DefaultView).CreateInstance(this.DragModel.NewElementType, (ISceneInsertionPoint)this.DragModel.InsertionPoint, rect, (OnCreateInstanceAction)null);
                double width  = child1.Width;
                double height = child1.Height;
                if (!double.IsNaN(width) || !double.IsNaN(height))
                {
                    BaseFrameworkElement child2 = (BaseFrameworkElement)this.DragModel.InsertionPoint.SceneNode;
                    Rect childRect = this.DragModel.ViewModel.GetLayoutDesignerForChild((SceneElement)child2, true).GetChildRect(child2);
                    rect.Width  = Math.Min(childRect.Width, 200.0);
                    rect.Height = Math.Min(childRect.Height, 300.0);
                    if (rect.Width != width || rect.Height != height)
                    {
                        this.DragModel.ViewModel.GetLayoutDesignerForChild((SceneElement)child1, true).SetChildRect(child1, rect);
                    }
                }
                IProperty targetProperty = this.ProjectContext.ResolveProperty(this.DragModel.NewElementProperty);
                if (this.SetBinding((SceneNode)child1, ref targetProperty))
                {
                    editTransaction.Commit();
                }
                else
                {
                    child1 = (BaseFrameworkElement)null;
                    editTransaction.Cancel();
                }
            }
            return(child1 != null);
        }
예제 #11
0
        public void OnDoubleClickItem(PartInPartsExplorer part)
        {
            SceneElement selectionToSet = (SceneElement)null;

            if (part.Status != PartStatus.Unused)
            {
                selectionToSet = this.viewModel.GetSceneNode(this.viewModel.ActiveEditingContainer.DocumentNode.NameScope.FindNode(part.Name)) as SceneElement;
            }
            else
            {
                using (SceneEditTransaction editTransaction = this.viewModel.CreateEditTransaction(StringTable.UndoDoubleClickToMakePart, false))
                {
                    KeyValuePair <ITypeId, ITypeId> keyValuePair     = Enumerable.FirstOrDefault <KeyValuePair <ITypeId, ITypeId> >((IEnumerable <KeyValuePair <ITypeId, ITypeId> >)PartsModel.instanceTypesForAbstractParts, (Func <KeyValuePair <ITypeId, ITypeId>, bool>)(pair => pair.Key.Equals((object)part.TargetType)));
                    BaseFrameworkElement            frameworkElement = keyValuePair.Key == null ? (BaseFrameworkElement)this.viewModel.CreateSceneNode(part.TargetType) : (BaseFrameworkElement)this.viewModel.CreateSceneNode(keyValuePair.Value);
                    frameworkElement.Name = part.Name;
                    this.viewModel.ActiveSceneInsertionPoint.Insert((SceneNode)frameworkElement);
                    selectionToSet = (SceneElement)frameworkElement;
                    editTransaction.Update();
                    if (frameworkElement.IsViewObjectValid)
                    {
                        editTransaction.Commit();
                    }
                    else
                    {
                        editTransaction.Cancel();
                        selectionToSet = (SceneElement)null;
                    }
                }
            }
            if (selectionToSet == null || !PlatformTypes.UIElement.IsAssignableFrom((ITypeId)selectionToSet.Type))
            {
                return;
            }
            this.viewModel.ClearSelections();
            this.viewModel.ElementSelectionSet.SetSelection(selectionToSet);
            this.viewModel.TimelineItemManager.EnsureExpandedAncestors(this.viewModel.TimelineItemManager.FindTimelineItem((SceneNode)selectionToSet));
        }
        private void CreateBinding(DataStorePropertyEntry propertyEntry)
        {
            string path = (string)null;
            bool   flag = false;
            DataStoreReferenceEntry storeReferenceEntry = (DataStoreReferenceEntry)null;

            using (SceneEditTransaction editTransaction = this.ObjectSet.ViewModel.CreateEditTransaction(StringTable.ConditionChangeUndo))
            {
                if (propertyEntry.Renamed || propertyEntry.IsCreateNewPropertyEntry)
                {
                    IEnumerable <DataStoreReferenceEntry> dataStoreDataSet = this.FindDataStoreDataSet((Predicate <SampleDataSet>)(dataSet => true));
                    if (dataStoreDataSet != null)
                    {
                        IEnumerable <DataStoreReferenceEntry> source = (IEnumerable <DataStoreReferenceEntry>)null;
                        if (propertyEntry.Renamed)
                        {
                            source = Enumerable.Where <DataStoreReferenceEntry>(dataStoreDataSet, (Func <DataStoreReferenceEntry, bool>)(entry => Enumerable.Count <SampleProperty>(Enumerable.Where <SampleProperty>((IEnumerable <SampleProperty>)entry.DataStore.RootType.SampleProperties, (Func <SampleProperty, bool>)(property => property.Name == propertyEntry.Name))) > 0));
                        }
                        if (source != null && Enumerable.FirstOrDefault <DataStoreReferenceEntry>(source) != null)
                        {
                            storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(source);
                            path = propertyEntry.Name;
                        }
                        else
                        {
                            storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(dataStoreDataSet);
                            if (propertyEntry.IsCreateNewPropertyEntry)
                            {
                                AddDataStorePropertyDialogModel model = new AddDataStorePropertyDialogModel(dataStoreDataSet);
                                bool?nullable = new GenericDialog("Resources\\DataPane\\AddDataStorePropertyDialog.xaml", StringTable.AddDataStorePropertyDialogTitle, (IGenericDialogModel)model).ShowDialog();
                                if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
                                {
                                    propertyEntry.Name  = model.PropertyName;
                                    storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(Enumerable.Where <DataStoreReferenceEntry>(dataStoreDataSet, (Func <DataStoreReferenceEntry, bool>)(entry => entry.DataStore.Name == model.SelectedDataStore)));
                                }
                                else
                                {
                                    this.editingProperty = this.lastEditingProperty;
                                    editTransaction.Cancel();
                                    this.Rebuild();
                                    return;
                                }
                            }
                            path = this.CreateNewProperty(storeReferenceEntry.DataStore, propertyEntry.Name);
                            flag = true;
                        }
                    }
                    if (storeReferenceEntry == null)
                    {
                        storeReferenceEntry = this.CreateNewDataStore(editTransaction);
                        if (storeReferenceEntry != null)
                        {
                            if (propertyEntry.IsCreateNewPropertyEntry)
                            {
                                IList <DataStoreReferenceEntry> list = (IList <DataStoreReferenceEntry>) new List <DataStoreReferenceEntry>();
                                list.Add(storeReferenceEntry);
                                AddDataStorePropertyDialogModel propertyDialogModel = new AddDataStorePropertyDialogModel((IEnumerable <DataStoreReferenceEntry>)list);
                                bool?nullable = new GenericDialog("Resources\\DataPane\\AddDataStorePropertyDialog.xaml", StringTable.AddDataStorePropertyDialogTitle, (IGenericDialogModel)propertyDialogModel).ShowDialog();
                                if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
                                {
                                    propertyEntry.Name = propertyDialogModel.PropertyName;
                                }
                                else
                                {
                                    this.editingProperty = this.lastEditingProperty;
                                    editTransaction.Cancel();
                                    this.Rebuild();
                                    return;
                                }
                            }
                            path = this.CreateNewProperty(storeReferenceEntry.DataStore, propertyEntry.Name);
                        }
                        flag = true;
                    }
                }
                else
                {
                    storeReferenceEntry = Enumerable.FirstOrDefault <DataStoreReferenceEntry>(this.FindDataStoreDataSet((Predicate <SampleDataSet>)(dataSet =>
                    {
                        if (dataSet.Name != propertyEntry.DataSetName)
                        {
                            return(false);
                        }
                        return(Enumerable.Count <SampleProperty>(Enumerable.Where <SampleProperty>((IEnumerable <SampleProperty>)dataSet.RootType.SampleProperties, (Func <SampleProperty, bool>)(property => property.Name == propertyEntry.Name))) > 0);
                    })));
                    path = propertyEntry.Name;
                }
                if (storeReferenceEntry != null && path != null)
                {
                    ISchema schemaForDataSource = SchemaManager.GetSchemaForDataSource(storeReferenceEntry.DictionaryEntryNode.Properties[DictionaryEntryNode.ValueProperty]);
                    this.ObjectSet.ViewModel.BindingEditor.CreateAndSetBindingOrData(this.OwnerObject, (IPropertyId)this.SceneNodeProperty.Reference.LastStep, this.PropertyNameEntry != null ? schemaForDataSource.CreateNodePath() : schemaForDataSource.GetNodePathFromPath(path), false);
                    if (this.PropertyNameEntry != null)
                    {
                        IType     type = this.ObjectSet.RepresentativeSceneNode.Type;
                        IProperty property;
                        for (property = (IProperty)null; property == null && type != null; type = type.BaseType)
                        {
                            property = type.GetMember(MemberType.LocalProperty, this.PropertyNameEntry, MemberAccessTypes.All) as IProperty;
                        }
                        if (property != null)
                        {
                            this.ObjectSet.RepresentativeSceneNode.SetValue((IPropertyId)property, (object)path);
                        }
                    }
                    propertyEntry.Name = path;
                }
                editTransaction.Commit();
                if (!flag)
                {
                    return;
                }
                DataStorePropertiesValueProvider.FireRebuildForAllProviders();
            }
        }
예제 #13
0
        private void ChangeRegistrationPoint(RegistrationPointFlags registrationPoint)
        {
            if (this.objectSet.ViewModel == null)
            {
                return;
            }
            bool flag1 = false;

            using (SceneEditTransaction editTransaction = this.objectSet.ViewModel.CreateEditTransaction(StringTable.UndoUnitTransformPaneCenterPoint))
            {
                Point point1 = this.CenterFromRegistrationPoint(registrationPoint);
                foreach (SceneElement sceneElement in this.objectSet.Objects)
                {
                    BaseFrameworkElement frameworkElement = sceneElement as BaseFrameworkElement;
                    if (frameworkElement != null)
                    {
                        flag1 = true;
                        CanonicalTransform canonicalTransform1 = new CanonicalTransform((Transform)frameworkElement.GetComputedValueAsWpf(this.PropertyReference));
                        CanonicalTransform canonicalTransform2 = new CanonicalTransform(canonicalTransform1);
                        if (this.IsRenderTransform)
                        {
                            Point point2 = (Point)frameworkElement.GetComputedValueAsWpf(Base2DElement.RenderTransformOriginProperty);
                            Rect  computedTightBounds = frameworkElement.GetComputedTightBounds();
                            Point oldOrigin           = new Point(point2.X * computedTightBounds.Width + computedTightBounds.Left, point2.Y * computedTightBounds.Height + computedTightBounds.Top);
                            Point newOrigin           = new Point(point1.X * computedTightBounds.Width + computedTightBounds.Left, point1.Y * computedTightBounds.Height + computedTightBounds.Top);
                            canonicalTransform2.UpdateForNewOrigin(oldOrigin, newOrigin);
                            bool flag2 = false;
                            if (!double.IsNaN(point1.X) && !object.Equals((object)point1.X, (object)point2.X))
                            {
                                point2.X = point1.X;
                                flag2    = true;
                            }
                            if (!double.IsNaN(point1.Y) && !object.Equals((object)point1.Y, (object)point2.Y))
                            {
                                point2.Y = point1.Y;
                                flag2    = true;
                            }
                            if (flag2)
                            {
                                frameworkElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)point2);
                            }
                        }
                        double num1 = RoundingHelper.RoundToDoublePrecision(canonicalTransform2.TranslationX, 6);
                        double num2 = RoundingHelper.RoundToDoublePrecision(canonicalTransform2.TranslationY, 6);
                        if (canonicalTransform1.TranslationX != num1)
                        {
                            frameworkElement.SetValue(this.TranslationXPropertyReference, (object)num1);
                        }
                        if (canonicalTransform1.TranslationY != num2)
                        {
                            frameworkElement.SetValue(this.TranslationYPropertyReference, (object)num2);
                        }
                    }
                }
                if (flag1)
                {
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }
 public override void Execute()
 {
     PerformanceUtility.StartPerformanceSequence(PerformanceEvent.EditStyleOrTemplate);
     if (this.IsEnabled)
     {
         SceneElement     targetElement                = this.TargetElement;
         IDocumentContext documentContext              = this.SceneViewModel.Document.DocumentContext;
         Type             propertyTargetType           = this.SceneViewModel.Document.ProjectContext.MetadataFactory.GetMetadata(this.Type.RuntimeType).GetStylePropertyTargetType((IPropertyId)this.TargetProperty);
         CreateResourceModel.ContextFlags contextFlags = !PlatformTypes.ControlTemplate.IsAssignableFrom((ITypeId)this.TargetProperty.PropertyType) ? (this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles) ? CreateResourceModel.ContextFlags.CanApplyAutomatically : CreateResourceModel.ContextFlags.None) : CreateResourceModel.ContextFlags.None;
         CreateResourceModel           model           = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, PlatformTypeHelper.GetPropertyType((IProperty)this.TargetProperty), propertyTargetType, this.TargetProperty.Name, (SceneElement)null, (SceneNode)(targetElement as BaseFrameworkElement), contextFlags);
         IList <DocumentCompositeNode> auxillaryResources;
         DocumentNode node1 = this.ProvideValue(out auxillaryResources);
         if (node1 != null)
         {
             IPropertyId           targetTypeProperty    = this.GetTargetTypeProperty((ITypeId)this.TargetProperty.PropertyType);
             DocumentCompositeNode documentCompositeNode = node1 as DocumentCompositeNode;
             if (targetTypeProperty != null && documentCompositeNode != null)
             {
                 IType valueAsType = DocumentPrimitiveNode.GetValueAsType(documentCompositeNode.Properties[targetTypeProperty]);
                 if (valueAsType != null && valueAsType.RuntimeType != (Type)null)
                 {
                     model.TargetType = valueAsType.RuntimeType;
                 }
             }
             else
             {
                 model.TargetType = (Type)null;
             }
             ReplaceStyleTemplateCommand.ExtraReferences references = new ReplaceStyleTemplateCommand.ExtraReferences();
             this.CollectExtraReferences(node1, references);
             if (auxillaryResources != null)
             {
                 foreach (DocumentNode node2 in (IEnumerable <DocumentCompositeNode>)auxillaryResources)
                 {
                     this.CollectExtraReferences(node2, references);
                 }
             }
             if (references.UnresolvedTypes.Count > 0)
             {
                 string message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.CopyStyleTemplateTypesNotInDocumentMessage, new object[2]
                 {
                     (object)this.TargetProperty.Name,
                     (object)SceneView.GetUnresolvedTypesList(references.UnresolvedTypes)
                 });
                 if (!this.ShowUI)
                 {
                     return;
                 }
                 this.DesignerContext.MessageDisplayService.ShowError(message);
                 return;
             }
             if (this.ShowUI)
             {
                 bool?nullable = new CreateResourceDialog(this.DesignerContext, model).ShowDialog();
                 if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0)
                 {
                     return;
                 }
             }
             bool flag = model.CurrentResourceSite != null;
             if (!flag || targetElement.DocumentNode.DocumentRoot == null)
             {
                 return;
             }
             SceneViewModel viewModel = this.SceneViewModel.GetViewModel(model.CurrentResourceSite.HostNode.DocumentRoot, false);
             if (viewModel == null || !PlatformTypes.PlatformsCompatible(node1.PlatformMetadata, viewModel.ProjectContext.PlatformMetadata) || !this.AddReferences(viewModel.ProjectContext, references, model.KeyString))
             {
                 return;
             }
             using (SceneEditTransaction editTransaction1 = this.SceneViewModel.CreateEditTransaction(this.UndoString))
             {
                 DocumentNode          documentNode1 = (DocumentNode)null;
                 DocumentCompositeNode resource;
                 using (SceneEditTransaction editTransaction2 = viewModel.CreateEditTransaction(this.UndoString))
                 {
                     DocumentNode newResourceNode;
                     try
                     {
                         newResourceNode = node1.Clone(viewModel.Document.DocumentContext);
                     }
                     catch
                     {
                         editTransaction2.Cancel();
                         editTransaction1.Cancel();
                         this.DesignerContext.MessageDisplayService.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.CommandFailedDialogMessage, new object[1]
                         {
                             (object)this.UndoString
                         }));
                         return;
                     }
                     newResourceNode.Name = (string)null;
                     bool useStaticResource = !(this.TargetProperty is DependencyPropertyReferenceStep) || !JoltHelper.TypeSupported((ITypeResolver)this.SceneViewModel.ProjectContext, PlatformTypes.DynamicResource);
                     int  index             = useStaticResource ? model.IndexInResourceSite(targetElement.DocumentNode) : -1;
                     resource = model.CreateResource(newResourceNode, targetTypeProperty, index);
                     flag     = resource != null;
                     if (flag)
                     {
                         documentNode1 = model.CreateResourceReference(this.SceneViewModel.Document.DocumentContext, resource, useStaticResource);
                         flag          = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CopyResourcesToNewResourceSite(auxillaryResources, viewModel, model.CurrentResourceSite.HostNode, resource, model.IndexInResourceSite((DocumentNode)resource));
                     }
                     if (flag)
                     {
                         editTransaction2.Commit();
                         if (this.SceneViewModel == viewModel)
                         {
                             editTransaction1.Update();
                             this.DesignerContext.ViewUpdateManager.UpdateRelatedViews(this.SceneViewModel.Document, false);
                         }
                         this.DesignerContext.ViewUpdateManager.RefreshActiveViewApplicationResources();
                     }
                     else
                     {
                         editTransaction2.Cancel();
                     }
                 }
                 if (flag && resource != null)
                 {
                     DocumentNode     documentNode2 = resource.Properties[DictionaryEntryNode.ValueProperty];
                     DocumentNodePath documentNodePath;
                     if (targetElement.IsAttached)
                     {
                         if (documentNode1 != null)
                         {
                             targetElement.SetValue(this.TargetPropertyReference, (object)documentNode1);
                         }
                         else
                         {
                             targetElement.ClearValue(this.TargetPropertyReference);
                         }
                         this.SceneView.CandidateEditingContainer = targetElement.DocumentNodePath;
                         editTransaction1.Update();
                         this.SceneView.CandidateEditingContainer = (DocumentNodePath)null;
                         documentNodePath = this.ProvideEditingContainer(targetElement, this.TargetPropertyReference, documentNode2);
                     }
                     else
                     {
                         documentNodePath = (DocumentNodePath)null;
                     }
                     if (this.SceneView.IsValid)
                     {
                         if (documentNodePath != null && documentNodePath.Node != null && (!DocumentNodeUtilities.IsDynamicResource(documentNodePath.Node) && !DocumentNodeUtilities.IsStaticResource(documentNodePath.Node)))
                         {
                             DocumentNode node2             = documentNodePath.Node;
                             bool         preferInPlaceEdit = ControlStylingOperations.CanEditInPlace(targetElement, this.TargetProperty, documentNodePath);
                             ControlStylingOperations.SetActiveEditingContainer(targetElement, this.TargetProperty, node2, documentNodePath, preferInPlaceEdit, editTransaction1);
                         }
                         else
                         {
                             ControlStylingOperations.SetActiveEditingContainer(targetElement, this.TargetProperty, documentNode2, (DocumentNodePath)null, false, editTransaction1);
                         }
                     }
                     editTransaction1.Commit();
                 }
                 else
                 {
                     editTransaction1.Cancel();
                 }
             }
         }
     }
     PerformanceUtility.EndPerformanceSequence(PerformanceEvent.EditStyleOrTemplate);
 }
예제 #15
0
        public static SceneNode CreateAndSetBindingOrData(DesignerContext designerContext, SceneNode target, ReferenceStep targetProperty)
        {
            SceneNode sceneNode = (SceneNode)null;

            using (DataBindingDialog dataBindingDialog = new DataBindingDialog(target, targetProperty))
            {
                bool?nullable = dataBindingDialog.ShowDialog();
                if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0)
                {
                    return((SceneNode)null);
                }
                using (target.ViewModel.AnimationEditor.DeferKeyFraming())
                {
                    using (SceneEditTransaction editTransaction = target.ViewModel.CreateEditTransaction(StringTable.UndoUnitSetBinding))
                    {
                        sceneNode = dataBindingDialog.model.CreateBindingOrData();
                        bool             flag    = sceneNode != null;
                        BindingSceneNode binding = sceneNode as BindingSceneNode;
                        if (binding != null)
                        {
                            flag = false;
                            if (binding.ElementBindingTarget != null)
                            {
                                binding.ElementBindingTarget.EnsureNamed();
                                binding.ElementName = binding.ElementBindingTarget.Name;
                            }
                            string errorMessage;
                            if (!binding.IsBindingLegal(target, targetProperty, out errorMessage))
                            {
                                MessageBoxArgs args = new MessageBoxArgs()
                                {
                                    Message = errorMessage,
                                    Button  = MessageBoxButton.OK,
                                    Image   = MessageBoxImage.Hand
                                };
                                int num = (int)designerContext.MessageDisplayService.ShowMessage(args);
                            }
                            else
                            {
                                IPropertyId propertyKey = (IPropertyId)targetProperty;
                                if (binding.Source != null)
                                {
                                    ISchema schema = dataBindingDialog.model.CurrentBindingSource.Schema;
                                    if (schema != null && schema.DataSource != null && schema.DataSource.DocumentNode != null)
                                    {
                                        propertyKey = BindingEditor.RefineDataContextProperty(target, (IPropertyId)targetProperty, schema.DataSource.DocumentNode);
                                    }
                                }
                                target.SetBinding(propertyKey, binding);
                                flag = true;
                            }
                        }
                        if (flag)
                        {
                            editTransaction.Commit();
                        }
                        else
                        {
                            editTransaction.Cancel();
                        }
                    }
                }
                return(sceneNode);
            }
        }
예제 #16
0
        protected override void ModifyValue(PropertyReferenceProperty property, object valueToSet, Modification modification, int index)
        {
            if (this.ViewModel == null)
            {
                return;
            }
            string description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1]
            {
                (object)((PropertyEntry)property).get_PropertyName()
            });

            if (!this.ViewModel.DefaultView.Document.IsEditable)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(description, false, SceneEditTransactionType.NestedInAutoClosing))
            {
                try
                {
                    foreach (SceneNode sceneNode1 in this.Objects)
                    {
                        PropertyReference propertyReference1 = SceneNodeObjectSet.FilterProperty(sceneNode1, property.Reference);
                        if (propertyReference1 != null)
                        {
                            SceneNode sceneNode2 = sceneNode1;
                            if (this.ShouldAllowAnimation)
                            {
                                SceneNode         ancestor           = (SceneNode)null;
                                PropertyReference propertyReference2 = propertyReference1;
                                if (this.FindAncestor(sceneNode1, out ancestor, ref propertyReference2, new Predicate <SceneNode>(SceneNodeObjectSetBase.IsAnimationParent)))
                                {
                                    sceneNode2         = ancestor;
                                    propertyReference1 = propertyReference2;
                                }
                            }
                            using (SceneNode.DisableEnsureTransform(PlatformTypes.TransformGroup.IsAssignableFrom((ITypeId)propertyReference1.LastStep.DeclaringType)))
                            {
                                if (modification == Modification.InsertValue)
                                {
                                    sceneNode2.InsertValue(propertyReference1, index, valueToSet);
                                }
                                else if (modification == Modification.ClearValue)
                                {
                                    this.ClearAnimations(sceneNode2, propertyReference1);
                                    sceneNode2.ClearValue(propertyReference1);
                                }
                                else if (modification == Modification.RemoveValue)
                                {
                                    SceneElement element = sceneNode2.GetLocalValueAsSceneNode(propertyReference1).GetChildren()[index] as SceneElement;
                                    if (element != null)
                                    {
                                        element.ViewModel.AnimationEditor.DeleteAllAnimationsInSubtree(element);
                                    }
                                    sceneNode2.RemoveValueAt(propertyReference1, index);
                                }
                                else if (modification == Modification.SetValue)
                                {
                                    this.ClearAnimations(sceneNode2, propertyReference1);
                                    using (LayoutRoundingHelper.IsUseLayoutRoundingProperty(sceneNode2, (IProperty)propertyReference1.LastStep) ? sceneNode2.ViewModel.ForceDefaultSetValue() : (IDisposable)null)
                                        sceneNode2.SetValue(propertyReference1, valueToSet);
                                }
                                LayoutRoundingHelper.ExplicitlyChangeLayoutRounding(sceneNode2, propertyReference1);
                            }
                        }
                    }
                    editTransaction.Commit();
                }
                catch (Exception ex)
                {
                    if (editTransaction != null)
                    {
                        editTransaction.Cancel();
                    }
                    int num = (int)this.DesignerContext.MessageDisplayService.ShowMessage(new MessageBoxArgs()
                    {
                        Message = StringTable.InvalidPropertyValueErrorNoException,
                        Button  = MessageBoxButton.OK,
                        Image   = MessageBoxImage.Hand
                    });
                }
            }
            this.TransactionContext.UpdateTransaction();
        }
예제 #17
0
        public override void Execute()
        {
            BaseFrameworkElement selectedElement = this.SelectedElement;

            if (selectedElement == null)
            {
                return;
            }
            IType type1 = this.SceneViewModel.ProjectContext.ResolveType(PlatformTypes.Style);

            CreateResourceModel.ContextFlags contextFlags = this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles) ? CreateResourceModel.ContextFlags.CanApplyAutomatically : CreateResourceModel.ContextFlags.None;
            if (this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles))
            {
                contextFlags = CreateResourceModel.ContextFlags.CanApplyAutomatically;
            }
            CreateResourceModel createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, this.DefaultContainerType.RuntimeType, PlatformTypes.Style.Name, (SceneElement)null, (SceneNode)selectedElement, contextFlags);

            if (this.ShowUI)
            {
                bool?nullable = this.CreateDialog(createResourceModel).ShowDialog();
                if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0)
                {
                    return;
                }
            }
            using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove())
            {
                using (SceneEditTransaction editTransaction1 = this.SceneViewModel.CreateEditTransaction(this.UndoString, false))
                {
                    using (this.SceneViewModel.ForceBaseValue())
                    {
                        using (this.SceneViewModel.DisableDrawIntoState())
                        {
                            this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)selectedElement);
                            this.SceneViewModel.ElementSelectionSet.Clear();
                            IDocumentContext documentContext = this.SceneViewModel.Document.DocumentContext;
                            IProjectContext  projectContext  = this.SceneViewModel.Document.ProjectContext;
                            Type             type2           = (Type)null;
                            if (createResourceModel.TargetTypeAsset != null && createResourceModel.TargetTypeAsset.EnsureTypeReferenced(this.SceneViewModel.ProjectContext as ProjectContext))
                            {
                                type2 = createResourceModel.TargetTypeAsset.Type.RuntimeType;
                            }
                            if (type2 == (Type)null)
                            {
                                type2 = createResourceModel.TargetType;
                            }
                            IType type3 = projectContext.GetType(type2);
                            DocumentCompositeNode documentCompositeNode1 = (DocumentCompositeNode)selectedElement.DocumentNode;
                            this.SceneViewModel.GetLayoutDesignerForChild((SceneElement)selectedElement, true).ClearUnusedLayoutProperties(selectedElement);
                            DocumentCompositeNode visualTreeNode            = documentContext.CreateNode((ITypeId)documentCompositeNode1.Type);
                            Dictionary <IProperty, DocumentNode> dictionary = new Dictionary <IProperty, DocumentNode>();
                            bool addRenderTransforms = false;
                            foreach (IPropertyId propertyId in this.GetLayoutProperties((SceneElement)selectedElement, addRenderTransforms))
                            {
                                IProperty property = this.DesignerContext.ActiveSceneViewModel.ProjectContext.ResolveProperty(propertyId);
                                if (property != null && documentCompositeNode1.Properties.Contains(property))
                                {
                                    dictionary.Add(property, documentCompositeNode1.Properties[(IPropertyId)property].Clone(documentContext));
                                    documentCompositeNode1.ClearValue((IPropertyId)property);
                                }
                            }
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties)
                            {
                                IPropertyId index = (IPropertyId)keyValuePair.Key;
                                DependencyPropertyReferenceStep propertyReferenceStep = index as DependencyPropertyReferenceStep;
                                if ((propertyReferenceStep == null || !propertyReferenceStep.IsAttachable || propertyReferenceStep.MemberType == MemberType.DesignTimeProperty) && (!index.Equals((object)BaseFrameworkElement.WidthProperty) && !index.Equals((object)BaseFrameworkElement.HeightProperty)))
                                {
                                    visualTreeNode.Properties[index] = keyValuePair.Value.Clone(documentContext);
                                }
                            }
                            if (documentCompositeNode1.SupportsChildren)
                            {
                                foreach (DocumentNode documentNode in (IEnumerable <DocumentNode>)documentCompositeNode1.Children)
                                {
                                    visualTreeNode.Children.Add(documentNode.Clone(documentContext));
                                }
                            }
                            if (!PlatformTypes.Panel.IsAssignableFrom((ITypeId)documentCompositeNode1.Type))
                            {
                                GridElement gridElement = (GridElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid);
                                SceneNode   sceneNode   = this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode);
                                gridElement.Children.Add(sceneNode);
                                visualTreeNode = (DocumentCompositeNode)gridElement.DocumentNode;
                            }
                            StyleNode styleNode = (StyleNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Style);
                            styleNode.StyleTargetTypeId = type3;
                            SetterSceneNode setterSceneNode = (SetterSceneNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Setter);
                            DependencyPropertyReferenceStep propertyReferenceStep1 = (DependencyPropertyReferenceStep)this.SceneViewModel.ProjectContext.ResolveProperty(ControlElement.TemplateProperty);
                            setterSceneNode.Property = propertyReferenceStep1;
                            BaseFrameworkElement  frameworkElement       = (BaseFrameworkElement)this.SceneViewModel.CreateSceneNode(type2);
                            DocumentCompositeNode documentCompositeNode2 = (DocumentCompositeNode)frameworkElement.DocumentNode;
                            this.AddPresenterIfNecessary(visualTreeNode, (SceneElement)frameworkElement);
                            ControlTemplateElement controlTemplateElement = (ControlTemplateElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.ControlTemplate);
                            controlTemplateElement.ControlTemplateTargetTypeId = (ITypeId)type3;
                            controlTemplateElement.DefaultInsertionPoint.Insert(this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode));
                            if (PlatformTypes.Button.Equals((object)type3) && controlTemplateElement.CanEditTriggers && this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                            {
                                DocumentCompositeNode node = documentContext.CreateNode(typeof(TriggerCollection));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsFocusedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsDefaultedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsMouseOverProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsPressedProperty, (object)true));
                                node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsEnabledProperty, (object)false));
                                controlTemplateElement.SetLocalValue(ControlTemplateElement.ControlTemplateTriggersProperty, (DocumentNode)node);
                            }
                            setterSceneNode.SetValueAsSceneNode(SetterSceneNode.ValueProperty, (SceneNode)controlTemplateElement);
                            styleNode.Setters.Add((SceneNode)setterSceneNode);
                            bool useStaticResource = !JoltHelper.TypeSupported((ITypeResolver)this.SceneViewModel.ProjectContext, PlatformTypes.DynamicResource);
                            int  index1            = -1;
                            if (useStaticResource && selectedElement.DocumentContext == createResourceModel.CurrentResourceSite.DocumentContext)
                            {
                                index1 = createResourceModel.IndexInResourceSite(selectedElement.DocumentNode);
                            }
                            IList <DocumentCompositeNode> referencedResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources((DocumentNode)documentCompositeNode1);
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in dictionary)
                            {
                                documentCompositeNode2.Properties[(IPropertyId)keyValuePair.Key] = keyValuePair.Value;
                            }
                            IList <SceneNode> nodes = (IList <SceneNode>) new List <SceneNode>();
                            nodes.Add((SceneNode)frameworkElement);
                            SceneNode parent           = selectedElement.Parent;
                            IProperty propertyForChild = parent.GetPropertyForChild((SceneNode)selectedElement);
                            ISceneNodeCollection <SceneNode> collectionForProperty = parent.GetCollectionForProperty((IPropertyId)propertyForChild);
                            int index2 = collectionForProperty.IndexOf((SceneNode)selectedElement);
                            collectionForProperty[index2] = (SceneNode)frameworkElement;
                            if (createResourceModel.SelectedResourceDictionary != null)
                            {
                                ResourceContainer instance = createResourceModel.SelectedResourceDictionary.Instance;
                                if (instance != null && instance.DocumentNode == documentCompositeNode1)
                                {
                                    createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, type2, PlatformTypes.Style.Name, (SceneElement)frameworkElement, (SceneNode)null, contextFlags);
                                }
                            }
                            if (createResourceModel.CurrentResourceSite != null && !PlatformTypes.PlatformsCompatible(createResourceModel.CurrentResourceSite.DocumentContext.TypeResolver.PlatformMetadata, styleNode.DocumentNode.PlatformMetadata))
                            {
                                editTransaction1.Cancel();
                                return;
                            }
                            DocumentCompositeNode resource = createResourceModel.CreateResource(styleNode.DocumentNode, StyleNode.TargetTypeProperty, index1);
                            if (resource == null)
                            {
                                editTransaction1.Cancel();
                                return;
                            }
                            DocumentNode            resourceReference = createResourceModel.CreateResourceReference(this.SceneViewModel.Document.DocumentContext, resource, useStaticResource);
                            DefaultTypeInstantiator typeInstantiator  = new DefaultTypeInstantiator(this.SceneView);
                            if (resourceReference != null)
                            {
                                documentCompositeNode2.Properties[BaseFrameworkElement.StyleProperty] = resourceReference;
                            }
                            foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties)
                            {
                                IPropertyId index3 = (IPropertyId)keyValuePair.Key;
                                DependencyPropertyReferenceStep propertyReferenceStep2 = index3 as DependencyPropertyReferenceStep;
                                if (propertyReferenceStep2 != null && propertyReferenceStep2.IsAttachable && propertyReferenceStep2.MemberType != MemberType.DesignTimeProperty)
                                {
                                    documentCompositeNode2.Properties[index3] = keyValuePair.Value.Clone(documentContext);
                                }
                            }
                            DocumentCompositeNode hostNode  = createResourceModel.CurrentResourceSite.HostNode;
                            SceneViewModel        viewModel = this.SceneViewModel.GetViewModel(hostNode.DocumentRoot, false);
                            using (SceneEditTransaction editTransaction2 = viewModel.CreateEditTransaction(this.UndoString))
                            {
                                Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CopyResourcesToNewResourceSite(referencedResources, viewModel, hostNode, resource, createResourceModel.IndexInResourceSite((DocumentNode)resource));
                                editTransaction2.Commit();
                            }
                            editTransaction1.Update();
                            if (this.SceneView.IsValid)
                            {
                                typeInstantiator.ApplyAfterInsertionDefaultsToElements(nodes, (SceneNode)null);
                            }
                            this.SceneView.CandidateEditingContainer = frameworkElement.DocumentNodePath;
                            editTransaction1.Update();
                            this.SceneViewModel.ElementSelectionSet.ExtendSelection((SceneElement)frameworkElement);
                            this.PostProcessing((SceneNode)selectedElement, (SceneNode)frameworkElement, resource);
                            if (frameworkElement.GetComputedValue(ControlElement.TemplateProperty) != null)
                            {
                                this.ActivateTemplateEditingMode((SceneElement)frameworkElement);
                            }
                            else
                            {
                                UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.ApplicationIdle, (Delegate) new Action <SceneElement>(this.ActivateTemplateEditingMode), (object)frameworkElement);
                            }
                            this.SceneView.CandidateEditingContainer = (DocumentNodePath)null;
                        }
                        editTransaction1.Commit();
                    }
                }
            }
        }
예제 #18
0
        public override void Execute(object arg)
        {
            ITypeId type = this.Type;

            if (type is ProjectNeutralTypeId && !this.SceneViewModel.ProjectContext.PlatformMetadata.IsSupported((ITypeResolver)this.SceneViewModel.ProjectContext, type))
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.DesignerContext.ActiveDocument.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitLayoutPaneChangeLayoutType, new object[1]
            {
                (object)this.Type.Name
            })))
            {
                bool           flag1 = false;
                SceneViewModel activeSceneViewModel         = this.DesignerContext.ActiveSceneViewModel;
                ReadOnlyCollection <SceneElement> selection = this.DesignerContext.SelectionManager.ElementSelectionSet.Selection;
                SceneElement        primarySelection1       = this.DesignerContext.SelectionManager.ElementSelectionSet.PrimarySelection;
                List <SceneElement> list                 = new List <SceneElement>();
                bool                 flag2               = false;
                bool                 flag3               = false;
                bool                 flag4               = false;
                SceneElement         sceneElement1       = (SceneElement)null;
                IStoryboardContainer storyboardContainer = (IStoryboardContainer)null;
                SceneElement         primarySelection2   = (SceneElement)null;
                this.DesignerContext.SelectionManager.ElementSelectionSet.Clear();
                List <SceneElement> elements = new List <SceneElement>();
                elements.AddRange((IEnumerable <SceneElement>)selection);
                ElementUtilities.SortElementsByDepth(elements);
                foreach (SceneElement sceneElement2 in elements)
                {
                    ITypeId typeId1 = (ITypeId)null;
                    foreach (ITypeId typeId2 in ChangeLayoutTypeFlyoutCommand.LayoutTypes)
                    {
                        if (typeId2.IsAssignableFrom((ITypeId)sceneElement2.Type))
                        {
                            typeId1 = typeId2;
                            break;
                        }
                    }
                    if (typeId1 == null)
                    {
                        list.Add(sceneElement2);
                    }
                    else
                    {
                        if (activeSceneViewModel.LockedInsertionPoint != null)
                        {
                            if (activeSceneViewModel.LockedInsertionPoint.SceneElement == sceneElement2)
                            {
                                flag2 = true;
                            }
                            else if (sceneElement2.IsAncestorOf((SceneNode)activeSceneViewModel.ActiveSceneInsertionPoint.SceneElement))
                            {
                                sceneElement1 = activeSceneViewModel.ActiveSceneInsertionPoint.SceneElement;
                                flag2         = true;
                            }
                        }
                        if (primarySelection1 == sceneElement2)
                        {
                            flag4 = true;
                        }
                        if (!flag3 && activeSceneViewModel.ActiveStoryboardContainer == sceneElement2)
                        {
                            activeSceneViewModel.SetActiveStoryboardTimeline((IStoryboardContainer)null, (StoryboardTimelineSceneNode)null, (TriggerBaseNode)null);
                            flag3 = true;
                        }
                        using (sceneElement2.ViewModel.ForceBaseValue())
                        {
                            BaseFrameworkElement     parent1           = sceneElement2 as BaseFrameworkElement;
                            List <LayoutCacheRecord> layoutCache       = (List <LayoutCacheRecord>)null;
                            ILayoutDesigner          designerForParent = activeSceneViewModel.GetLayoutDesignerForParent(sceneElement2, true);
                            if (parent1 != null)
                            {
                                layoutCache = designerForParent.GetCurrentRects(parent1);
                            }
                            SceneElement elementContainingChildren = (SceneElement)null;
                            SceneElement sceneElement3             = ChangeLayoutTypeCommand.ChangeLayoutType(sceneElement2, type, ref elementContainingChildren);
                            editTransaction.Update();
                            if (sceneElement3.IsViewObjectValid)
                            {
                                this.SceneViewModel.DefaultView.UpdateLayout();
                                BaseFrameworkElement parent2 = elementContainingChildren as BaseFrameworkElement;
                                if (parent2 != null && parent2.IsViewObjectValid && layoutCache != null)
                                {
                                    activeSceneViewModel.GetLayoutDesignerForParent(elementContainingChildren, true).SetCurrentRects(parent2, layoutCache);
                                }
                                if (flag2 && sceneElement1 == null)
                                {
                                    sceneElement1 = elementContainingChildren;
                                }
                                if (flag3 && storyboardContainer == null)
                                {
                                    storyboardContainer = (IStoryboardContainer)sceneElement3;
                                }
                                if (flag4 && primarySelection2 == null)
                                {
                                    primarySelection2 = sceneElement3;
                                }
                                list.Add(sceneElement3);
                            }
                            flag1 = true;
                        }
                    }
                }
                if (flag2 && sceneElement1 != null)
                {
                    activeSceneViewModel.SetLockedInsertionPoint(sceneElement1);
                }
                if (flag3 && storyboardContainer != null)
                {
                    activeSceneViewModel.SetActiveStoryboardTimeline(storyboardContainer, (StoryboardTimelineSceneNode)null, (TriggerBaseNode)null);
                }
                this.DesignerContext.SelectionManager.ElementSelectionSet.SetSelection((ICollection <SceneElement>)list, primarySelection2);
                if (flag1)
                {
                    editTransaction.Commit();
                }
                else
                {
                    editTransaction.Cancel();
                }
            }
        }
예제 #19
0
        public override void Execute()
        {
            SceneElement targetElement = this.TargetElement;

            if (targetElement is StyleNode)
            {
                this.useStyle = new bool?(false);
            }
            else
            {
                IList <DocumentCompositeNode> auxillaryResources1;
                DocumentNode documentNode1 = this.ProvideCurrentStyle(targetElement, this.Type, new PropertyReference((ReferenceStep)targetElement.ProjectContext.ResolveProperty(BaseFrameworkElement.StyleProperty)), false, out auxillaryResources1);
                IList <DocumentCompositeNode> auxillaryResources2;
                DocumentNode other = this.ProvideCurrentTemplate(targetElement, new PropertyReference(this.ActiveTemplateProperty), out auxillaryResources2);
                bool         flag  = false;
                if ((other == null || other.DocumentRoot == null) && documentNode1 != null)
                {
                    using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitEditCopyStyle, true))
                    {
                        if (auxillaryResources1 != null && auxillaryResources1.Count > 0)
                        {
                            ResourceSite resourceSite = new ResourceSite(targetElement.DocumentNode);
                            resourceSite.EnsureResourceCollection();
                            foreach (DocumentCompositeNode entryNode in (IEnumerable <DocumentCompositeNode>)auxillaryResources1)
                            {
                                DocumentNode resourceEntryKey = ResourceNodeHelper.GetResourceEntryKey(entryNode);
                                DocumentNode documentNode2    = entryNode.Properties[DictionaryEntryNode.ValueProperty];
                                if (resourceEntryKey != null && documentNode2 != null)
                                {
                                    DictionaryEntryNode dictionaryEntryNode = (DictionaryEntryNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.DictionaryEntry);
                                    dictionaryEntryNode.KeyNode = this.SceneViewModel.GetSceneNode(resourceEntryKey.Clone(this.SceneViewModel.Document.DocumentContext));
                                    dictionaryEntryNode.Value   = this.SceneViewModel.GetSceneNode(documentNode2.Clone(this.SceneViewModel.Document.DocumentContext));
                                    resourceSite.ResourcesDictionary.Children.Add(dictionaryEntryNode.DocumentNode);
                                }
                            }
                        }
                        documentNode1 = documentNode1.Clone(this.SceneViewModel.Document.DocumentContext);
                        DocumentCompositeNode documentCompositeNode = documentNode1 as DocumentCompositeNode;
                        if (documentCompositeNode != null && documentCompositeNode.NameProperty != null && documentCompositeNode.Properties.Contains(documentCompositeNode.NameProperty))
                        {
                            documentCompositeNode.ClearValue((IPropertyId)documentCompositeNode.NameProperty);
                        }
                        targetElement.SetValue(this.TargetPropertyReference, (object)documentNode1);
                        DocumentNodePath valueAsDocumentNode = targetElement.GetLocalValueAsDocumentNode(this.TargetPropertyReference);
                        documentNode1 = valueAsDocumentNode != null ? valueAsDocumentNode.Node : (DocumentNode)null;
                        editTransaction.Update();
                        object computedValue = targetElement.GetComputedValue(new PropertyReference(this.ActiveTemplateProperty));
                        if (computedValue != null)
                        {
                            DocumentNodePath correspondingNodePath = this.SceneView.GetCorrespondingNodePath(this.SceneViewModel.ProjectContext.Platform.ViewObjectFactory.Instantiate(computedValue), true);
                            if (correspondingNodePath != null)
                            {
                                flag  = valueAsDocumentNode.IsAncestorOf(correspondingNodePath);
                                other = correspondingNodePath != null ? correspondingNodePath.Node : other;
                            }
                        }
                        editTransaction.Cancel();
                    }
                }
                this.useStyle = new bool?(flag || other != null && documentNode1 != null && documentNode1.IsAncestorOf(other));
            }
            base.Execute();
            this.useStyle = new bool?();
        }
예제 #20
0
        protected void DoDrop(DragEventArgs eventArgs, int destinationIndex)
        {
            IDataObject data = eventArgs.Data;

            if (this.ResourceManager.IsFiltering)
            {
                return;
            }
            ResourceEntryItem resourceEntry = (ResourceEntryItem)null;

            if (!this.CanDrop(eventArgs, out resourceEntry) || resourceEntry == this)
            {
                return;
            }
            ResourceContainer dropTargetContainer = this.DragDropTargetContainer;

            if (resourceEntry.Container == dropTargetContainer)
            {
                if ((eventArgs.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey)
                {
                    using (SceneEditTransaction editTransaction = resourceEntry.Container.ViewModel.CreateEditTransaction(StringTable.UndoUnitCopyResource))
                    {
                        DocumentCompositeNode entryNode = resourceEntry.Resource.ResourceNode.Clone(dropTargetContainer.ViewModel.Document.DocumentContext) as DocumentCompositeNode;
                        DocumentNode          keyNode   = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.GenerateUniqueResourceKey(resourceEntry.Key.ToString(), dropTargetContainer.Node);
                        ResourceNodeHelper.SetResourceEntryKey(entryNode, keyNode);
                        Microsoft.Expression.DesignSurface.Utility.ResourceHelper.AddResource((DictionaryEntryNode)dropTargetContainer.ViewModel.GetSceneNode((DocumentNode)entryNode), dropTargetContainer.ResourceDictionaryNode, destinationIndex);
                        editTransaction.Commit();
                    }
                }
                else
                {
                    resourceEntry.Container.MoveItem(resourceEntry, destinationIndex);
                }
            }
            else
            {
                ObservableCollection <string> observableCollection = new ObservableCollection <string>();
                observableCollection.Add(dropTargetContainer.DocumentContext.DocumentUrl);
                bool skipReferencedResourceCopy = this.IsContainerReachable((IEnumerable <string>)observableCollection, resourceEntry.Container);
                if ((eventArgs.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey)
                {
                    this.CopyItem(resourceEntry, dropTargetContainer, destinationIndex, skipReferencedResourceCopy);
                }
                else
                {
                    ReferencesFoundModel referencingResources = resourceEntry.InteractiveGetReferencingResources(ReferencesFoundModel.UseScenario.DeleteResource);
                    if (referencingResources == null)
                    {
                        return;
                    }
                    bool doReferenceFixup = false;
                    if (referencingResources.ReferenceNames.Count > 0 && !this.IsContainerReachable((IEnumerable <string>)referencingResources.ScenesWithReferences, dropTargetContainer))
                    {
                        if (!new ReferencesFoundDialog(referencingResources).ShowDialog().GetValueOrDefault(false))
                        {
                            return;
                        }
                        doReferenceFixup = referencingResources.SelectedUpdateMethod != ReferencesFoundModel.UpdateMethod.DontFix;
                    }
                    if (dropTargetContainer.ViewModel == resourceEntry.Container.ViewModel)
                    {
                        using (SceneEditTransaction editTransaction = dropTargetContainer.ViewModel.CreateEditTransaction(StringTable.UndoUnitMoveResource))
                        {
                            if (this.MoveItem(resourceEntry, dropTargetContainer, destinationIndex, skipReferencedResourceCopy, referencingResources, doReferenceFixup))
                            {
                                editTransaction.Commit();
                            }
                            else
                            {
                                editTransaction.Cancel();
                            }
                        }
                    }
                    else
                    {
                        this.MoveItem(resourceEntry, dropTargetContainer, destinationIndex, skipReferencedResourceCopy, referencingResources, doReferenceFixup);
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }