コード例 #1
0
ファイル: CmdLineTarget.cs プロジェクト: adrianhara/SvgToXaml
        public int BuildDict(
            [ArgumentParam(Aliases = "i", Desc = "dir to the SVGs", LongDesc = "specify folder of the graphic files to process")]
            string inputdir,
            [ArgumentParam(Aliases = "o", LongDesc = "Name for the xaml outputfile")]
            string outputname,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "folder for the xaml-Output, optional, default: folder of svgs")]
            string outputdir = null,
            [ArgumentParam(LongDesc = "Builds a htmlfile to browse the svgs, optional, default true")]
            bool buildhtmlfile = true,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "Prefix to name alll items of this file, optional, default: no prefix")]
            string nameprefix = null,
            [ArgumentParam(DefaultValue = false, ExplicitNeeded = false, LongDesc = "If true, es explicit ResourceKey File is created, default: false", ExplicitWantedArguments = "resKeyNS,resKeyNSName")]
            bool useComponentResKeys = false,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "Namespace to use with UseResKey")]
            string compResKeyNS = null,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "name of Namespace to use with UseResKey")]
            string compResKeyNSName = null,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "Extract child elements into separate resources, default true")]
            bool extractChildElements = true,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "If true will not use hardcoded Brush values but rather a binding to SvgConvertedImageSourceBehavior that can be used to dynamically set the image color. Set this behavior on Images. Use together with extractChildElements:false.", ExplicitWantedArguments = "extractChildElements")]
            bool useSvgConvertedImageSourceBehavior = false
            )
        {
            Console.WriteLine("Building resource dictionary...");
            var outFileName = Path.Combine(outputdir ?? inputdir, outputname);

            if (!Path.HasExtension(outFileName))
            {
                outFileName = Path.ChangeExtension(outFileName, ".xaml");
            }

            var resKeyInfo = new ResKeyInfo
            {
                Name                 = null,
                XamlName             = Path.GetFileNameWithoutExtension(outputname),
                Prefix               = nameprefix,
                UseComponentResKeys  = useComponentResKeys,
                NameSpace            = compResKeyNS,
                NameSpaceName        = compResKeyNSName,
                ExtractChildElements = extractChildElements,
                UseSvgConvertedImageSourceBehavior = useSvgConvertedImageSourceBehavior
            };

            File.WriteAllText(outFileName, ConverterLogic.SvgDirToXaml(inputdir, resKeyInfo, null));
            Console.WriteLine("xaml written to: {0}", outFileName);

            if (buildhtmlfile)
            {
                var htmlFilePath = Path.Combine(inputdir,
                                                Path.GetFileNameWithoutExtension(outputname));
                var files = ConverterLogic.SvgFilesFromFolder(inputdir);
                BuildHtmlBrowseFile(files, htmlFilePath);
            }
            return(0); //no Error
        }
コード例 #2
0
        public int BuildDict(
            [ArgumentParam(Aliases = "i", Desc = "dir to the SVGs", LongDesc = "specify folder of the graphic files to process")]
            string inputdir,
            [ArgumentParam(Aliases = "o", LongDesc = "Name for the xaml outputfile")]
            string outputname,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "folder for the xaml-Output, optional, default: folder of svgs")]
            string outputdir = null,
            [ArgumentParam(LongDesc = "Builds a htmlfile to browse the svgs, optional, default true")]
            bool buildhtmlfile = true,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "Prefix to name all items of this file, optional, default: no prefix")]
            string nameprefix = null,
            [ArgumentParam(DefaultValue = false, ExplicitNeeded = false, LongDesc = "If true, es explicit ResourceKey File is created, default: false", ExplicitWantedArguments = "resKeyNS,resKeyNSName")]
            bool useComponentResKeys = false,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "Namespace to use with UseResKey")]
            string compResKeyNS = null,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "name of Namespace to use with UseResKey")]
            string compResKeyNSName = null,
            [ArgumentParam(DefaultValue = false, ExplicitNeeded = false, LongDesc = "If true, PixelsPerDip is filtered to ensure compatibility for < 4.6.2, default: false")]
            bool filterPixelsPerDip = false,
            [ArgumentParam(DefaultValue = false, ExplicitNeeded = false, LongDesc = "Recursive goes through inputdir subfolders")]
            bool handleSubFolders = false
            )
        {
            Console.WriteLine("Building resource dictionary...");
            var outFileName = Path.Combine(outputdir ?? inputdir, outputname);

            if (!Path.HasExtension(outFileName))
            {
                outFileName = Path.ChangeExtension(outFileName, ".xaml");
            }

            var resKeyInfo = new ResKeyInfo
            {
                Name                = null,
                XamlName            = Path.GetFileNameWithoutExtension(outputname),
                Prefix              = nameprefix,
                UseComponentResKeys = useComponentResKeys,
                NameSpace           = compResKeyNS,
                NameSpaceName       = compResKeyNSName,
            };

            File.WriteAllText(outFileName, ConverterLogic.SvgDirToXaml(inputdir, resKeyInfo, null, filterPixelsPerDip, handleSubFolders, true));
            Console.WriteLine("xaml written to: {0}", outFileName);

            if (buildhtmlfile)
            {
                var htmlFilePath = Path.Combine(inputdir,
                                                Path.GetFileNameWithoutExtension(outputname));
                var files = ConverterLogic.SvgFilesFromFolder(inputdir);
                BuildHtmlBrowseFile(files, htmlFilePath);
            }
            return(0); //no Error
        }
コード例 #3
0
        public int BuildDict(
            [ArgumentParam(Aliases = "i", Desc = "dir to the SVGs", LongDesc = "specify folder of the graphic files to process")]
            string inputdir,
            [ArgumentParam(Aliases = "o", LongDesc = "Name for the xaml outputfile")]
            string outputname,
            [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "folder for the xaml-Output, optional, default: folder of svgs")]
            string outputdir = null,
            [ArgumentParam(LongDesc = "Builds a htmlfile to browse the svgs, optional, default true")]
            bool buildhtmlfile = true)
        {
            Console.WriteLine("Building resource dictionary...");

            string outFileName;

            if (outputdir != null)
            {
                outFileName = Path.Combine(outputdir, outputname);
            }
            else
            {
                outFileName = Path.Combine(inputdir, outputname);
            }
            if (!Path.HasExtension(outFileName))
            {
                outFileName = Path.ChangeExtension(outFileName, ".xaml");
            }

            File.WriteAllText(outFileName, ConverterLogic.SvgDirToXaml(inputdir, Path.GetFileNameWithoutExtension(outputname)));
            Console.WriteLine("xaml written to: {0}", outFileName);

            if (buildhtmlfile)
            {
                var htmlFilePath = System.IO.Path.Combine(inputdir,
                                                          System.IO.Path.GetFileNameWithoutExtension(outputname));
                var files = ConverterLogic.SvgFilesFromFolder(inputdir);
                BuildHtmlBrowseFile(files, htmlFilePath);
            }
            return(0); //no Error
        }