Пример #1
0
    /// <summary>
    /// Checks that PSD files contain only features from a predefined list
    /// </summary>
    private static void CheckPsdFeatures()
    {
        var filenames = new string[]
        {
            "Mug.psd",
            "UnsupportedFeatures.psd"
        };

        // A list of features that can be correctly handled by a renderer

        var renderSupportedFeatures = new PsdFeature[]
        {
            PsdFeature.LayerTypeRaster,
            PsdFeature.LayerTypeSmartObject,
            PsdFeature.BlendModeNormal,
            PsdFeature.ColorModeRgb,
            PsdFeature.ChannelSize8bit
        };

        foreach (var filename in filenames)
        {
            using (var psdReader = new PsdReader("../../../../_Input/" + filename))
            {
                if (psdReader.CheckFeatures(renderSupportedFeatures))
                {
                    Console.WriteLine("File {0} is valid", filename);
                }
                else
                {
                    Console.WriteLine("File {0} is not valid", filename);
                }
            }
        }
    }
Пример #2
0
    /// <summary>
    /// Writes a message with a list of unsupported features
    /// </summary>
    private static void CheckPsdFeaturesWithOutput()
    {
        using (var psdReader = new PsdReader("../../../../_Input/UnsupportedFeatures.psd"))
        {
            var renderSupportedFeatures = new PsdFeature[]
            {
                PsdFeature.LayerTypeRaster,
                PsdFeature.BlendModeNormal,
                PsdFeature.ColorModeRgb,
                PsdFeature.ChannelSize8bit
            };

            string output = string.Empty;
            psdReader.CheckFeatures(renderSupportedFeatures, ref output);

            Console.WriteLine(output);
        }
    }
Пример #3
0
    /// <summary>
    /// Uses custom messages in the output string
    /// </summary>
    private static void CheckPsdFeaturesWithCustomOutput()
    {
        using (var psdReader = new PsdReader("../../../../_Input/UnsupportedFeatures.psd"))
        {
            var renderSupportedFeatures = new PsdFeature[]
            {
                PsdFeature.LayerTypeRaster,
                PsdFeature.BlendModeNormal,
                PsdFeature.ColorModeRgb,
                PsdFeature.ChannelSize8bit
            };

            string output = string.Empty;
            var    rm     = new System.Resources.ResourceManager("ValidatePsd.Properties.CheckPsdFeatures", System.Reflection.Assembly.GetExecutingAssembly());
            psdReader.CheckFeatures(renderSupportedFeatures, ref output, rm);

            Console.WriteLine(output);
        }
    }