Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        private static bool CompareMaterials(Material firstMaterial, Material secondMaterial)
        {
            if (firstMaterial.GetType() != secondMaterial.GetType())
            {
                return(false);
            }
            MaterialGroup materialGroup1 = firstMaterial as MaterialGroup;

            if (materialGroup1 != null)
            {
                MaterialGroup materialGroup2 = (MaterialGroup)secondMaterial;
                if (materialGroup1.Children.Count != materialGroup2.Children.Count)
                {
                    return(false);
                }
                for (int index = 0; index < materialGroup1.Children.Count; ++index)
                {
                    if (!PropertyUtilities.CompareMaterials(materialGroup1.Children[index], materialGroup2.Children[index]))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            DiffuseMaterial diffuseMaterial1 = firstMaterial as DiffuseMaterial;

            if (diffuseMaterial1 != null)
            {
                DiffuseMaterial diffuseMaterial2 = (DiffuseMaterial)secondMaterial;
                return(PropertyUtilities.CompareBrushes(diffuseMaterial1.Brush, diffuseMaterial2.Brush));
            }
            EmissiveMaterial emissiveMaterial1 = firstMaterial as EmissiveMaterial;

            if (emissiveMaterial1 != null)
            {
                EmissiveMaterial emissiveMaterial2 = (EmissiveMaterial)secondMaterial;
                return(PropertyUtilities.CompareBrushes(emissiveMaterial1.Brush, emissiveMaterial2.Brush));
            }
            SpecularMaterial specularMaterial1 = firstMaterial as SpecularMaterial;

            if (specularMaterial1 == null)
            {
                return(object.Equals((object)firstMaterial, (object)secondMaterial));
            }
            SpecularMaterial specularMaterial2 = (SpecularMaterial)secondMaterial;

            if (specularMaterial1.SpecularPower == specularMaterial2.SpecularPower)
            {
                return(PropertyUtilities.CompareBrushes(specularMaterial1.Brush, specularMaterial2.Brush));
            }
            return(false);
        }