예제 #1
0
        /// <summary>
        /// 初始化对话框
        /// </summary>
        /// <returns></returns>
        private static bool InitDialog()
        {
            string dir = JsSaver.BaseSavePath;

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            dir = JsSaver.BaseSavePath + "artDialog/";
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            else
            {
                return(true);
            }

            using (MemoryStream mem = new MemoryStream(ARTDialogReource.artdialog))
            {
                SharpUnZipFile unZip = new SharpUnZipFile(mem);
                unZip.UnZipFiles(dir);
                File.WriteAllText(dir + "artDialogShow.js", ARTDialogReource.artdialogshow, Encoding.UTF8);
            }

            return(true);
        }
예제 #2
0
        private void EncodeZip(string fileName, string savePath)
        {
            string tempPath = savePath + "\\temp\\";

            //FileInfo efinfo = new FileInfo(fileName);
            ShowMessage("正在预编码");
            string unzipPath = tempPath + "\\unzip\\" + Path.GetFileNameWithoutExtension(fileName) + "\\";

            unzipPath = unzipPath.Replace("\\\\", "\\");
            using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                SharpUnZipFile zip = new SharpUnZipFile(file);
                zip.UnZipFiles(unzipPath);
            }

            string         jsonPath = unzipPath + "animation.json";
            string         json     = File.ReadAllText(jsonPath);
            FramePackInfos info     = new FramePackInfos();

            info.PixivID = Path.GetFileNameWithoutExtension(fileName);
            List <FrameItem> lstFrame = JsonConvert.DeserializeObject <List <FrameItem> >(json);

            info.Frames = lstFrame;
            string[] files = Directory.GetFiles(unzipPath);
            if (files.Length > 0)
            {
                FileInfo finfo = new FileInfo(files[0]);


                using (Image bmp = Bitmap.FromFile(files[0]))
                {
                    info.PicSize = bmp.Size;
                }
            }

            string perPack = tempPath + "\\pack\\" + Path.GetFileNameWithoutExtension(fileName) + "\\";

            perPack = perPack.Replace("\\\\", "\\");
            if (!Directory.Exists(perPack))
            {
                Directory.CreateDirectory(perPack);
            }



            SavePerPack(perPack, unzipPath, info);

            ShowMessage("正在转码");
            try
            {
                RunEncode(perPack, savePath, info, 8);
            }
            finally
            {
                Directory.Delete(unzipPath, true);
                Directory.Delete(perPack, true);
            }
        }