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 IEnumerable <ReferenceStep> GetPropertiesForSceneNode(SceneNode node)
        {
            TextRangeElement textRange = node as TextRangeElement;

            if (textRange != null)
            {
                foreach (IPropertyId propertyId in textRange.RangeProperties)
                {
                    DependencyPropertyReferenceStep dp = node.ProjectContext.ResolveProperty(propertyId) as DependencyPropertyReferenceStep;
                    if (dp != null)
                    {
                        yield return((ReferenceStep)dp);
                    }
                }
            }
            else
            {
                foreach (IProperty property in ITypeExtensions.GetProperties(PropertyMerger.GetTypeFromSceneNode(node), MemberAccessTypes.Public, true))
                {
                    ReferenceStep referenceStep = property as ReferenceStep;
                    if (referenceStep != null)
                    {
                        DependencyPropertyReferenceStep dependencyPropertyReferenceStep = referenceStep as DependencyPropertyReferenceStep;
                        if (dependencyPropertyReferenceStep == null || !dependencyPropertyReferenceStep.IsAttachable)
                        {
                            yield return(referenceStep);
                        }
                    }
                }
            }
        }
Beispiel #3
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);
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public static IList <TargetedReferenceStep> GetMergedProperties(IEnumerable <SceneNode> selectedSceneNodes)
 {
     if (selectedSceneNodes == null || !Enumerable.Any <SceneNode>(selectedSceneNodes))
     {
         return((IList <TargetedReferenceStep>) new List <TargetedReferenceStep>());
     }
     return((IList <TargetedReferenceStep>)PropertyMerger.GetPropertiesFromSelection(selectedSceneNodes));
 }
Beispiel #5
0
 private static void OnAttachedPropertiesFinishedScanning(object sender, EventArgs e)
 {
     ((IAttachedPropertiesMetadata)sender).FinishedScanning -= new EventHandler(PropertyMerger.OnAttachedPropertiesFinishedScanning);
     if (PropertyMerger.PropertiesUpdated == null)
     {
         return;
     }
     PropertyMerger.PropertiesUpdated((object)null, EventArgs.Empty);
 }
Beispiel #6
0
 public int Compare(TargetedReferenceStep r1, TargetedReferenceStep r2)
 {
     return(PropertyMerger.ReferenceStepCompare(r1, r2));
 }