예제 #1
0
        void OutputCaptions(System.IO.DirectoryInfo output, Output_aa[] converters, int size)
        {
            //xslt��ǂݍ���
            var xsltDoc = new XmlDocument();
            var xslt_args = new System.Xml.Xsl.XsltArgumentList();
            xsltDoc.LoadXml(Properties.Resources.Xslt);
            xslt_args.AddParam("Mode", "", "Movie");

            for (int i = 0; i < converters.Length; i++)
                using (var fileStrm = new System.IO.FileStream(output.FullName + "\\" + _jsName + i + ".js", System.IO.FileMode.Create))
                using (var bmp = new System.Drawing.Bitmap(_bmpFiles[i].OpenRead()))
                {
                    xslt_args.AddParam("captionIndex", "", i);
                    converters[i] = new Output_aa(bmp, _chars);
                    converters[i].ReducingImage += delegate(object sender, EventArgs e)
                    {
                        Console.WriteLine(i + "�ԖڊJ�n");
                    };
                    converters[i].CreatingHtml += delegate(object sender, EventArgs e)
                    {
                        Console.WriteLine(i + "�Ԗڊ���");
                    };

                    converters[i].Transform(size, fileStrm, xsltDoc, xslt_args);
                    xslt_args.RemoveParam("captionIndex", "");
                }
        }
예제 #2
0
        public void ConvertAsciiArt(string[] CommandLine, SettingInfo setting)
        {
            IOutput output;
            for (int i = 0; i < CommandLine.Length; i++)
            {
                Console.WriteLine("\r\n" + System.IO.Path.GetFileName(CommandLine[i]));
                var imageNameWithoutEx = System.IO.Path.GetFileNameWithoutExtension(CommandLine[i]);
                var outputFileInfo = new System.IO.FileInfo(setting.Path.FullName + "\\" + imageNameWithoutEx + ".htm");

                Bitmap bmp;//����������ʓ|�Ȃ̂œ������B
                switch (setting.Mode)
                {
                    case SettingInfo.ConvertMode.HtmlArt:
                        if (!System.IO.File.Exists(CommandLine[i]))
                        {
                            Console.WriteLine("�w�肳�ꂽ�t�@�C�������݂��܂���ł����B\r\n" + CommandLine[i]);
                            continue;
                        }
                        bmp = new Bitmap(CommandLine[i]);
                        output = new Output_txt(bmp, setting.Chars);
                        break;
                    case SettingInfo.ConvertMode.AsciiArt:
                        if (!System.IO.File.Exists(CommandLine[i]))
                        {
                            Console.WriteLine("�w�肳�ꂽ�t�@�C�������݂��܂���ł����B\r\n" + CommandLine[i]);
                            continue;
                        }
                        bmp = new Bitmap(CommandLine[i]);
                        output = new Output_aa(bmp, setting.Chars);
                        break;
                    case SettingInfo.ConvertMode.Movie:
                        if (!System.IO.Directory.Exists(CommandLine[i]))
                        {
                            Console.WriteLine("�w�肳�ꂽ�p�X�̓t�H���_�Ƃ��ĔF������܂���ł����B\r\n" + CommandLine[i]);
                            continue;
                        }
                        output = new Output_movie(new System.IO.DirectoryInfo(CommandLine[i]), setting.Chars);
                        break;
                    default:
                        Console.WriteLine("�\�z�O�̏�Ԃ��������܂����B�摜�̏�����X�L�b�v���܂��B");
                        continue;
                }

                output.ReducingImage += output_Reducting;
                output.CreatingHtml += output_CreateHtml;
                output.Convert(outputFileInfo, setting.Size);
                Console.WriteLine("[�������� : {0}]", imageNameWithoutEx + ".htm");
            }
        }
예제 #3
0
        public void Convert(System.IO.FileInfo output, int size)
        {
            var converters = new Output_aa[_bmpFiles.Length];
            var captionDire = new System.IO.DirectoryInfo(output.Directory.FullName + "\\Captions");
            var cssFileInfo = new System.IO.FileInfo(output.Directory.FullName + "\\" + System.IO.Path.GetFileNameWithoutExtension(output.Name) + ".css");
            var jsFileInfo = new System.IO.FileInfo(output.Directory.FullName + "\\" + System.IO.Path.GetFileNameWithoutExtension(output.Name) + ".js");
            captionDire.Create();

            //Js�t�@�C���𐶐�
            OutputCaptions(captionDire, converters, size);

            //��i�{�̂ł���html�𐶐�����
            using (var fileStrm = new System.IO.FileStream(output.FullName, System.IO.FileMode.Create))
            {
                var htmlDocBase = new XmlDocument();
                var importList = htmlDocBase.CreateElement("import-files");

                //���搧��p�̃X�N���v�g�̎Q��
                var main_js = htmlDocBase.CreateElement("file");
                main_js.AppendChild(htmlDocBase.CreateTextNode(jsFileInfo.Name));
                importList.AppendChild(main_js);
                //�e�t���[���̕������i�[�����X�N���v�g�̎Q��
                for (int i = 0; i < converters.Length; i++)
                {
                    var item = htmlDocBase.CreateElement("file");
                    item.AppendChild(htmlDocBase.CreateTextNode(captionDire.Name + "/" + _jsName + i + ".js"));
                    importList.AppendChild(item);
                }
                htmlDocBase.AppendChild(importList);

                var xsltDoc = new XmlDocument();
                var xsl = new System.Xml.Xsl.XslCompiledTransform(true);
                var xsl_args = new System.Xml.Xsl.XsltArgumentList();
                xsltDoc.LoadXml(Properties.Resources.Xslt);

                xsl_args.AddParam("StyleSheetHref", "", cssFileInfo.Name);
                xsl_args.AddParam("Mode", "", "MoviePlayer");
                xsl.Load(xsltDoc);
                xsl.Transform(htmlDocBase, xsl_args, fileStrm);
            }

            //css &JavaScript�̏����o��
            System.IO.File.WriteAllText(cssFileInfo.FullName, Properties.Resources.Style_AA);
            System.IO.File.WriteAllText(jsFileInfo.FullName, Properties.Resources.JScript);
        }