Ejemplo n.º 1
0
        private static int ReferenceStepCompare(TargetedReferenceStep r1, TargetedReferenceStep r2)
        {
            if (r1 == r2)
            {
                return(0);
            }
            DependencyPropertyReferenceStep propertyReferenceStep1 = r1.ReferenceStep as DependencyPropertyReferenceStep;
            DependencyPropertyReferenceStep propertyReferenceStep2 = r2.ReferenceStep as DependencyPropertyReferenceStep;

            if (propertyReferenceStep1 != null && propertyReferenceStep2 != null && propertyReferenceStep1.DependencyProperty == propertyReferenceStep2.DependencyProperty)
            {
                return(0);
            }
            int num = string.Compare(r1.ReferenceStep.Name, r2.ReferenceStep.Name, StringComparison.Ordinal);

            if (num != 0)
            {
                return(num);
            }
            if (r1.ReferenceStep.PropertyType.Equals((object)r2.ReferenceStep.PropertyType) && r1.ReferenceStep.MemberType == r2.ReferenceStep.MemberType)
            {
                return(0);
            }
            return(string.Compare(r1.ReferenceStep.DeclaringType.UniqueName, r2.ReferenceStep.DeclaringType.UniqueName, StringComparison.Ordinal));
        }
Ejemplo n.º 2
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);
        }