Пример #1
0
        private void HeavySave()
        {
            try
            {
                // ヘビーセーブ形式で保存する.
                if (savefilebitmap == null)
                {
                    return;
                }

                // まずPNG形式のデータを作る.
                MemoryStream basepng = new MemoryStream();
                savefilebitmap.Save(basepng, System.Drawing.Imaging.ImageFormat.Png);
                // PNGFileクラスにデータを取り込む.
                PNGHSAVStream pngstream = new PNGHSAVStream();
                basepng.Seek(0, SeekOrigin.Begin);
                PNGFile png = pngstream.GetPNG(basepng);

                // TSOデータを読み込んで組み立てる.
                if (fDisplayed == false)
                {
                    DisplayTso();
                }

                //TSOデータを設定する.
                foreach (PNGTsoData tsodata in tsoDataList)
                {
                    pngstream.get.Add(tsodata);
                }
                // 保存先を決める.
                string savefile_dir  = TDCGExplorer.TDCGExplorer.SystemDB.savefile_directory;
                string savefile_name = Path.GetFileNameWithoutExtension(filename) + ".png";

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.FileName         = filename;
                dialog.InitialDirectory = TDCGExplorer.TDCGExplorer.SystemDB.savefile_directory;
                dialog.Filter           = TextResource.PNGSaveFileDescription;
                dialog.FilterIndex      = 0;
                dialog.Title            = TextResource.SelectSaveFileName;
                dialog.RestoreDirectory = true;
                dialog.OverwritePrompt  = true;
                dialog.CheckPathExists  = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string destpath = dialog.FileName;

                    // 保存先をオープン.
                    //File.Delete(destpath);
                    TDCGExplorer.TDCGExplorer.FileDelete(destpath);
                    using (Stream output = File.Create(destpath))
                    {
                        // PNGを出力する.
                        pngstream.SavePNGFile(png, output);
                    }
                    // ファイルを追加する.
                    TDCGExplorer.TDCGExplorer.AddFileTree(destpath);
                }
            }
            catch (Exception ex)
            {
                TDCGExplorer.TDCGExplorer.SetToolTips(TextResource.Error + ":" + ex.Message);
            }
        }