Beispiel #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PropertyReferencePropertyValue referencePropertyValue = value as PropertyReferencePropertyValue;

            if (referencePropertyValue != null)
            {
                SceneNodeProperty sceneNodeProperty = referencePropertyValue.OwnerProperty as SceneNodeProperty;
                if (sceneNodeProperty != null)
                {
                    IProjectContext projectContext = sceneNodeProperty.SceneNodeObjectSet.ProjectContext;
                    if (projectContext == null)
                    {
                        return(null);
                    }
                    Type runtimeType1 = projectContext.ResolveType(ProjectNeutralTypes.BehaviorEventTriggerBase).RuntimeType;
                    Type runtimeType2 = projectContext.ResolveType(ProjectNeutralTypes.BehaviorTargetedTriggerAction).RuntimeType;
                    Type type         = sceneNodeProperty.ObjectSet.ObjectType;
                    while (type != (Type)null && type.BaseType != (Type)null && (!type.BaseType.Equals(runtimeType1) && !type.BaseType.Equals(runtimeType2)))
                    {
                        type = type.BaseType;
                    }
                    Type[] genericArguments = type.GetGenericArguments();
                    if (genericArguments.Length > 0)
                    {
                        return((object)projectContext.GetType(genericArguments[0]));
                    }
                    return((object)type);
                }
            }
            return(null);
        }
        public void CreateNewEventTrigger()
        {
            if (this.CurrentContainer == null)
            {
                return;
            }
            SceneViewModel    activeSceneViewModel = this.ActiveSceneViewModel;
            SceneDocument     document             = activeSceneViewModel.Document;
            ITriggerContainer currentContainer     = this.CurrentContainer;

            using (SceneEditTransaction editTransaction = document.CreateEditTransaction(StringTable.TriggerChangeUndoUnit))
            {
                IProjectContext projectContext = document.ProjectContext;
                IType           type           = projectContext.GetType(currentContainer.TargetElementType);
                if (type != null)
                {
                    TriggerSourceInformation triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultEvent((ITypeResolver)projectContext, type);
                    if (triggerSource != (TriggerSourceInformation)null)
                    {
                        TriggerBaseNode trigger = TriggersHelper.CreateTrigger(triggerSource, activeSceneViewModel);
                        if (trigger != null)
                        {
                            int index = currentContainer.VisualTriggers.Count;
                            if (this.selectedItem != null)
                            {
                                index = this.selectedItem != this.noneTrigger ? currentContainer.VisualTriggers.IndexOf(this.selectedItem.SceneNode) + 1 : 0;
                            }
                            currentContainer.VisualTriggers.Insert(index, trigger);
                            this.TriggerToBeSelected = trigger;
                        }
                    }
                }
                editTransaction.Commit();
            }
        }
Beispiel #3
0
        public static void CreateDefaultTrigger(StoryboardTimelineSceneNode storyboard)
        {
            ITriggerContainer triggerContainer = (ITriggerContainer)storyboard.StoryboardContainer ?? storyboard.ViewModel.RootNode as ITriggerContainer;

            if (triggerContainer == null || !triggerContainer.CanEditTriggers)
            {
                return;
            }
            SceneViewModel  viewModel      = storyboard.ViewModel;
            IProjectContext projectContext = viewModel.ProjectContext;
            IType           type           = projectContext.GetType(triggerContainer.TargetElementType);

            if (type == null)
            {
                return;
            }
            TriggerSourceInformation triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultEvent((ITypeResolver)projectContext, type);

            if (!(triggerSource != (TriggerSourceInformation)null))
            {
                return;
            }
            TriggerBaseNode orCreateTrigger = TriggersHelper.FindOrCreateTrigger(triggerSource, triggerContainer, viewModel);

            if (orCreateTrigger == null)
            {
                return;
            }
            TimelineActionNode timelineActionNode = (TimelineActionNode)BeginActionNode.Factory.Instantiate(viewModel);

            timelineActionNode.TargetTimeline = storyboard;
            TriggersHelper.DefaultAddAction(orCreateTrigger, (TriggerActionNode)timelineActionNode);
        }
Beispiel #4
0
        public override SceneNode CreatePrototypeInstance(ISceneInsertionPoint insertionPoint)
        {
            IProjectContext projectContext = insertionPoint.SceneNode.ProjectContext;
            IType           type1          = projectContext.ResolveType((ITypeId)this.Type);
            IType           type2          = projectContext.GetType(type1.RuntimeAssembly.Name, type1.FullName) ?? projectContext.Platform.Metadata.GetType(type1.RuntimeType);

            if (type2 != null)
            {
                return(new DefaultTypeInstantiator(insertionPoint.SceneNode.ViewModel.DefaultView).CreatePrototypeInstance((ITypeId)type2));
            }
            return((SceneNode)null);
        }
Beispiel #5
0
        public ICodeAidTypeInfo GetTypeByName(string uri, string typeName)
        {
            IProjectContext projectContext = this.ProjectContext;
            IXmlNamespace   xmlNamespace   = (IXmlNamespace)XmlNamespace.ToNamespace(uri, XmlNamespace.GetNamespaceCanonicalization((ITypeResolver)projectContext));

            if (xmlNamespace == null)
            {
                return((ICodeAidTypeInfo)null);
            }
            IType type = projectContext.GetType(xmlNamespace, typeName);

            if (type != null)
            {
                return((ICodeAidTypeInfo) new CodeAidTypeInfo(this, type));
            }
            return((ICodeAidTypeInfo)null);
        }
Beispiel #6
0
        public static StyleNode CreateEmptyStyle(SceneViewModel sceneViewModel, IPropertyId propertyKey, ITypeId elementType)
        {
            IProperty       property       = sceneViewModel.ProjectContext.ResolveProperty(propertyKey);
            StyleNode       styleNode      = (StyleNode)sceneViewModel.CreateSceneNode(PlatformTypes.Style);
            IProjectContext projectContext = sceneViewModel.ProjectContext;
            Type            type1          = projectContext.MetadataFactory.GetMetadata(projectContext.ResolveType(elementType).RuntimeType).GetStylePropertyTargetType((IPropertyId)property);

            if (type1 == (Type)null && !projectContext.IsCapabilitySet(PlatformCapability.SupportsStyleWithoutTargetType))
            {
                type1 = projectContext.PlatformMetadata.ResolveType(PlatformTypes.FrameworkElement).RuntimeType;
            }
            if (type1 != (Type)null)
            {
                IType type2 = projectContext.GetType(type1);
                styleNode.StyleTargetTypeId = type2;
            }
            return(styleNode);
        }
Beispiel #7
0
        private IEnumerable <IType> GetAllAttachedPropertyTypesInProject()
        {
            IProjectContext             project            = this.ProjectContext;
            IAttachedPropertiesProvider propertiesProvider = this.AttachedPropertiesProvider;

            if (propertiesProvider == null)
            {
                throw new NotSupportedException();
            }
            using (IAttachedPropertiesAccessToken token = propertiesProvider.AttachedProperties.Access())
            {
                CodeAidProvider.EnsurePreloadKnownAttachedProperties(token, project);
                return((IEnumerable <IType>)Enumerable.ToArray <IType>(Enumerable.Select(Enumerable.Where(Enumerable.Select(Enumerable.GroupBy <IAttachedPropertyMetadata, Type>((IEnumerable <IAttachedPropertyMetadata>)token.AllAttachedProperties(), (Func <IAttachedPropertyMetadata, Type>)(property => property.OwnerType)), typeGroup => new
                {
                    typeGroup = typeGroup,
                    type = project.GetType(typeGroup.Key)
                }), param0 => param0.type != null), param0 => param0.type)));
            }
        }
        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();
                    }
                }
            }
        }
Beispiel #9
0
        private IEnumerable <IType> AllXamlRelevantTypesInAssembly(IAssembly assembly)
        {
            IProjectContext project         = this.ProjectContext;
            bool            supportInternal = assembly.Equals((object)project.ProjectAssembly);

            Type[] assemblyTypes = Type.EmptyTypes;
            try
            {
                assemblyTypes = AssemblyHelper.GetTypes(assembly);
            }
            catch (ReflectionTypeLoadException ex)
            {
                assemblyTypes = Type.EmptyTypes;
            }
            IAttachedPropertiesProvider attachedPropertiesProvider = this.AttachedPropertiesProvider;

            if (attachedPropertiesProvider == null)
            {
                throw new NotSupportedException();
            }
            Type[] allTypesWithAttachedProperties = (Type[])null;
            using (IAttachedPropertiesAccessToken token = attachedPropertiesProvider.AttachedProperties.Access())
            {
                CodeAidProvider.EnsurePreloadKnownAttachedProperties(token, project);
                allTypesWithAttachedProperties = Enumerable.ToArray <Type>(Enumerable.Select <IGrouping <Type, IAttachedPropertyMetadata>, Type>(Enumerable.GroupBy <IAttachedPropertyMetadata, Type>((IEnumerable <IAttachedPropertyMetadata>)token.AttachedPropertiesForAssembly(assembly.Name), (Func <IAttachedPropertyMetadata, Type>)(property => property.OwnerType)), (Func <IGrouping <Type, IAttachedPropertyMetadata>, Type>)(type => type.Key)));
            }
            foreach (Type type3 in assemblyTypes)
            {
                IType yieldedTypeId = (IType)null;
                try
                {
                    if (!type3.IsGenericType)
                    {
                        if (type3.IsVisible)
                        {
                            if (!type3.IsNested)
                            {
                                if (!typeof(Attribute).IsAssignableFrom(type3))
                                {
                                    if (!typeof(Exception).IsAssignableFrom(type3))
                                    {
                                        if (type3.IsPublic)
                                        {
                                            if (TypeUtilities.HasDefaultConstructor(type3, supportInternal) && TypeUtilities.CanCreateTypeInXaml((ITypeResolver)project, type3))
                                            {
                                                IType type1 = project.GetType(type3);
                                                if (JoltHelper.TypeSupported((ITypeResolver)project, (ITypeId)type1))
                                                {
                                                    yieldedTypeId = type1;
                                                }
                                            }
                                            else if (allTypesWithAttachedProperties != null)
                                            {
                                                if (OrderedListExtensions.GenericBinarySearch <Type, Type>(allTypesWithAttachedProperties, type3, (Func <Type, Type, int>)((type1, type2) => type1.Name.CompareTo(type2.Name))) >= 0)
                                                {
                                                    yieldedTypeId = project.GetType(type3);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (FileNotFoundException ex)
                {
                }
                if (yieldedTypeId != null)
                {
                    yield return(yieldedTypeId);
                }
            }
        }
Beispiel #10
0
        public IEnumerable <ICodeAidTypeInfo> GetAttachedPropertyTypesInClrNamespace(string assembly, string namespaceName)
        {
            IProjectContext project = this.ProjectContext;

            if (string.IsNullOrEmpty(assembly))
            {
                assembly = this.ProjectContext.ProjectAssembly.Name;
            }
            IAttachedPropertiesProvider propertiesProvider = this.AttachedPropertiesProvider;

            if (propertiesProvider == null)
            {
                throw new NotSupportedException();
            }
            using (IAttachedPropertiesAccessToken propertiesAccessToken = propertiesProvider.AttachedProperties.Access())
                return(Enumerable.Select <IGrouping <Type, IAttachedPropertyMetadata>, ICodeAidTypeInfo>(Enumerable.GroupBy <IAttachedPropertyMetadata, Type>((IEnumerable <IAttachedPropertyMetadata>)propertiesAccessToken.AttachedPropertiesForAssemblyAndNamespace(assembly, namespaceName), (Func <IAttachedPropertyMetadata, Type>)(property => property.OwnerType)), (Func <IGrouping <Type, IAttachedPropertyMetadata>, ICodeAidTypeInfo>)(typeGroup => (ICodeAidTypeInfo) new CodeAidTypeInfo(this, project.GetType(typeGroup.Key)))));
        }
        private void ResolveDefaultStyle(SceneElement targetElement, object defaultStyleKey, bool allowDefaultStyle, out DocumentNode currentStyle, out bool isThemeStyle, out IList <DocumentCompositeNode> auxillaryResources)
        {
            IProjectContext      projectContext1      = this.SceneViewModel.ProjectContext;
            ThemeContentProvider themeContentProvider = this.DesignerContext.ThemeContentProvider;

            currentStyle       = (DocumentNode)null;
            isThemeStyle       = false;
            auxillaryResources = (IList <DocumentCompositeNode>)null;
            if (defaultStyleKey == null)
            {
                return;
            }
            IAssembly runtimeAssembly = targetElement.Type.RuntimeAssembly;
            IAssembly targetAssembly  = PlatformTypeHelper.GetTargetAssembly(targetElement.Type);
            Type      type1           = defaultStyleKey as Type;

            if (type1 != (Type)null)
            {
                ITypeId typeId = (ITypeId)projectContext1.GetType(type1);
                if (typeId != null)
                {
                    IType type2 = projectContext1.ResolveType(typeId);
                    runtimeAssembly = type2.RuntimeAssembly;
                    targetAssembly  = PlatformTypeHelper.GetTargetAssembly(type2);
                }
            }
            IAssembly designAssembly = projectContext1.GetDesignAssembly(runtimeAssembly);

            if (designAssembly != null)
            {
                currentStyle = themeContentProvider.GetThemeResourceFromAssembly(projectContext1, designAssembly, designAssembly, defaultStyleKey, out auxillaryResources);
                if (currentStyle != null)
                {
                    return;
                }
            }
            if (!PlatformTypes.IsPlatformType((ITypeId)this.Type))
            {
                foreach (IProject project in this.DesignerContext.ProjectManager.CurrentSolution.Projects)
                {
                    IProjectContext projectContext2 = (IProjectContext)ProjectXamlContext.GetProjectContext(project);
                    if (projectContext2 != null && runtimeAssembly.Equals((object)projectContext2.ProjectAssembly))
                    {
                        currentStyle = themeContentProvider.GetThemeResourceFromProject(project, defaultStyleKey, out auxillaryResources);
                        if (currentStyle != null)
                        {
                            return;
                        }
                    }
                }
            }
            else if (!allowDefaultStyle || projectContext1.PlatformMetadata.TargetFramework.Identifier == ".NETFramework" && projectContext1.PlatformMetadata.TargetFramework.Version < projectContext1.PlatformMetadata.RuntimeFramework.Version)
            {
                currentStyle = themeContentProvider.GetThemeResourceFromPlatform(projectContext1.Platform, defaultStyleKey, out auxillaryResources);
                if (currentStyle != null)
                {
                    isThemeStyle = true;
                    return;
                }
            }
            if (!projectContext1.IsCapabilitySet(PlatformCapability.IsWpf))
            {
                currentStyle = themeContentProvider.GetThemeResourceFromAssembly(projectContext1, runtimeAssembly, targetAssembly, defaultStyleKey, out auxillaryResources);
                isThemeStyle = currentStyle != null;
            }
            else
            {
                object resource = this.SceneViewModel.FindResource(defaultStyleKey);
                if (resource == null)
                {
                    return;
                }
                if (projectContext1 != null && projectContext1.IsCapabilitySet(PlatformCapability.VsmInToolkit) && (projectContext1.IsCapabilitySet(PlatformCapability.SupportsVisualStateManager) && projectContext1.PlatformMetadata.IsNullType((ITypeId)projectContext1.ResolveType(ProjectNeutralTypes.VisualStateManager))))
                {
                    IAssembly usingAssemblyName = projectContext1.Platform.Metadata.GetPlatformAssemblyUsingAssemblyName(targetElement.Type.RuntimeAssembly);
                    if (usingAssemblyName == null || !AssemblyHelper.IsPlatformAssembly(usingAssemblyName))
                    {
                        IDocumentContext documentContext = (IDocumentContext) new DocumentContext((IProjectContext) new ToolkitProjectContext(projectContext1), ((DocumentContext)this.SceneViewModel.Document.DocumentContext).DocumentLocator);
                        DocumentNode     node            = documentContext.CreateNode(resource.GetType(), resource);
                        if (ProjectAttributeHelper.GetDefaultStateRecords(this.Type, (ITypeResolver)(documentContext.TypeResolver as ProjectContext)).Count > 0 || (DocumentCompositeNode)node.FindFirst(new Predicate <DocumentNode>(this.SelectVisualStateGroupPredicate)) != null)
                        {
                            ToolkitHelper.AddToolkitReferenceIfNeeded((ITypeResolver)projectContext1, this.DesignerContext.ViewUpdateManager);
                        }
                    }
                }
                SceneNode sceneNode = this.SceneViewModel.CreateSceneNode(resource);
                if (!PlatformTypes.Style.IsAssignableFrom((ITypeId)sceneNode.Type))
                {
                    return;
                }
                currentStyle = sceneNode.DocumentNode;
            }
        }