Beispiel #1
0
        public static List <TargetedReferenceStep> GetPropertiesFromSelection(IEnumerable <SceneNode> selectedSceneNodes)
        {
            List <TargetedReferenceStep> properties         = new List <TargetedReferenceStep>();
            ProjectXamlContext           projectXamlContext = (ProjectXamlContext)Enumerable.First <SceneNode>(selectedSceneNodes).ProjectContext;

            PropertyMerger.GetMergedPropertiesForSelection(selectedSceneNodes, properties);
            PropertyMerger.ReferenceStepComparer referenceStepComparer = new PropertyMerger.ReferenceStepComparer();
            int count = properties.Count;

            using (IAttachedPropertiesAccessToken propertiesAccessToken = projectXamlContext.AttachedProperties.Access())
            {
                if (!projectXamlContext.AttachedProperties.IsFinished)
                {
                    projectXamlContext.AttachedProperties.FinishedScanning += new EventHandler(PropertyMerger.OnAttachedPropertiesFinishedScanning);
                }
                foreach (IAttachedPropertyMetadata propertyMetadata in propertiesAccessToken.AllAttachedProperties())
                {
                    IType type = projectXamlContext.GetType(propertyMetadata.OwnerType);
                    if (type != null)
                    {
                        DependencyPropertyReferenceStep propertyReferenceStep = type.GetMember(MemberType.AttachedProperty, propertyMetadata.Name, MemberAccessTypes.Public) as DependencyPropertyReferenceStep;
                        if (propertyReferenceStep != null)
                        {
                            TargetedReferenceStep targetedReferenceStep = new TargetedReferenceStep((ReferenceStep)propertyReferenceStep, propertyReferenceStep.DeclaringType);
                            if (properties.BinarySearch(0, count, targetedReferenceStep, (IComparer <TargetedReferenceStep>)referenceStepComparer) < 0)
                            {
                                properties.Add(targetedReferenceStep);
                            }
                        }
                    }
                }
            }
            return(properties);
        }
Beispiel #2
0
        private static void GetMergedPropertiesForSelection(IEnumerable <SceneNode> selectedSceneNodes, List <TargetedReferenceStep> properties)
        {
            PropertyMerger.ReferenceStepComparer referenceStepComparer = new PropertyMerger.ReferenceStepComparer();
            HashSet <IType> hashSet = new HashSet <IType>();
            bool            flag    = true;

            foreach (SceneNode sceneNode in selectedSceneNodes)
            {
                IType typeFromSceneNode = PropertyMerger.GetTypeFromSceneNode(sceneNode);
                if (hashSet.Add(typeFromSceneNode))
                {
                    List <TargetedReferenceStep> list = new List <TargetedReferenceStep>();
                    foreach (ReferenceStep referenceStep in PropertyMerger.GetPropertiesForSceneNode(sceneNode))
                    {
                        list.Add(new TargetedReferenceStep(referenceStep, typeFromSceneNode));
                    }
                    list.Sort((IComparer <TargetedReferenceStep>)referenceStepComparer);
                    if (flag)
                    {
                        properties.AddRange((IEnumerable <TargetedReferenceStep>)list);
                        flag = false;
                    }
                    else
                    {
                        for (int index = properties.Count - 1; index >= 0; --index)
                        {
                            if (list.BinarySearch(properties[index], (IComparer <TargetedReferenceStep>)referenceStepComparer) < 0)
                            {
                                properties.RemoveAt(index);
                            }
                        }
                    }
                }
            }
        }