示例#1
0
        private static bool Compare(object first, object second, int depth)
        {
            if (depth > 3)
            {
                return(true);
            }
            Brush firstBrush  = first as Brush;
            Brush secondBrush = second as Brush;

            if (firstBrush != null && secondBrush != null)
            {
                return(PropertyUtilities.CompareBrushes(firstBrush, secondBrush));
            }
            GradientStopCollection firstStops;
            GradientStopCollection secondStops;

            if ((firstStops = first as GradientStopCollection) != null && (secondStops = second as GradientStopCollection) != null)
            {
                return(PropertyUtilities.CompareGradientStops(firstStops, secondStops));
            }
            TextDecorationCollection firstTextDecorationCollection;
            TextDecorationCollection secondTextDecorationCollection;

            if ((firstTextDecorationCollection = first as TextDecorationCollection) != null && (secondTextDecorationCollection = second as TextDecorationCollection) != null)
            {
                return(PropertyUtilities.CompareTextDecorations(firstTextDecorationCollection, secondTextDecorationCollection));
            }
            AxisAngleRotation3D axisAngleRotation3D1;
            AxisAngleRotation3D axisAngleRotation3D2;

            if ((axisAngleRotation3D1 = first as AxisAngleRotation3D) != null && (axisAngleRotation3D2 = second as AxisAngleRotation3D) != null)
            {
                if (axisAngleRotation3D1.Angle == axisAngleRotation3D2.Angle)
                {
                    return(axisAngleRotation3D1.Axis == axisAngleRotation3D2.Axis);
                }
                return(false);
            }
            Material firstMaterial;
            Material secondMaterial;

            if ((firstMaterial = first as Material) != null && (secondMaterial = second as Material) != null)
            {
                return(PropertyUtilities.CompareMaterials(firstMaterial, secondMaterial));
            }
            Freezable firstFreezable;
            Freezable secondFreezable;

            if ((firstFreezable = first as Freezable) != null && (secondFreezable = second as Freezable) != null)
            {
                return(PropertyUtilities.CompareFreezables(firstFreezable, secondFreezable, depth));
            }
            return(object.Equals(first, second));
        }
示例#2
0
        private static bool CompareBrushes(Brush firstBrush, Brush secondBrush)
        {
            if (firstBrush == null && secondBrush == null)
            {
                return(true);
            }
            if (firstBrush == null || secondBrush == null)
            {
                return(false);
            }
            Type type1 = firstBrush.GetType();
            Type type2 = secondBrush.GetType();

            if (type1 != type2)
            {
                return(false);
            }
            if (type1 == typeof(SolidColorBrush))
            {
                return(((SolidColorBrush)firstBrush).Color == ((SolidColorBrush)secondBrush).Color);
            }
            GradientBrush gradientBrush1;

            if ((gradientBrush1 = firstBrush as GradientBrush) != null)
            {
                GradientBrush gradientBrush2 = (GradientBrush)secondBrush;
                if (gradientBrush1.MappingMode != gradientBrush2.MappingMode || gradientBrush1.SpreadMethod != gradientBrush2.SpreadMethod)
                {
                    return(false);
                }
                LinearGradientBrush linearGradientBrush1 = gradientBrush1 as LinearGradientBrush;
                if (linearGradientBrush1 != null)
                {
                    LinearGradientBrush linearGradientBrush2 = (LinearGradientBrush)gradientBrush2;
                    if (linearGradientBrush1.EndPoint != linearGradientBrush2.EndPoint || linearGradientBrush1.StartPoint != linearGradientBrush2.StartPoint)
                    {
                        return(false);
                    }
                }
                else
                {
                    RadialGradientBrush radialGradientBrush1;
                    if ((radialGradientBrush1 = gradientBrush1 as RadialGradientBrush) != null)
                    {
                        RadialGradientBrush radialGradientBrush2 = (RadialGradientBrush)gradientBrush2;
                        if (radialGradientBrush1.Center != radialGradientBrush2.Center || radialGradientBrush1.RadiusX != radialGradientBrush2.RadiusX || (radialGradientBrush1.RadiusY != radialGradientBrush2.RadiusY || radialGradientBrush1.GradientOrigin != radialGradientBrush2.GradientOrigin))
                        {
                            return(false);
                        }
                    }
                }
                Transform transform1 = gradientBrush1.Transform;
                Transform transform2 = gradientBrush2.Transform;
                if (transform1 == null || transform2 == null || new CanonicalTransform(transform1) != new CanonicalTransform(transform2))
                {
                    return(false);
                }
                return(PropertyUtilities.CompareGradientStops(gradientBrush1.GradientStops, gradientBrush2.GradientStops));
            }
            TileBrush tileBrush1;

            if ((tileBrush1 = firstBrush as TileBrush) == null)
            {
                return(object.Equals((object)firstBrush, (object)secondBrush));
            }
            TileBrush tileBrush2 = (TileBrush)secondBrush;

            if (tileBrush1.AlignmentX != tileBrush2.AlignmentX || tileBrush1.AlignmentY != tileBrush2.AlignmentY || (tileBrush1.RelativeTransform != tileBrush2.RelativeTransform || tileBrush1.Stretch != tileBrush2.Stretch) || (tileBrush1.TileMode != tileBrush2.TileMode || tileBrush1.Viewbox != tileBrush2.Viewbox || (tileBrush1.ViewboxUnits != tileBrush2.ViewboxUnits || tileBrush1.Viewport != tileBrush2.Viewport)) || tileBrush1.ViewportUnits != tileBrush2.ViewportUnits)
            {
                return(false);
            }
            Transform transform3 = tileBrush1.Transform;
            Transform transform4 = tileBrush2.Transform;

            return((transform3 != null || transform4 == null) && (transform3 == null || transform4 != null) && !(new CanonicalTransform(transform3) != new CanonicalTransform(transform4)));
        }