public void Save(string Filename) { SaveForm SF = new SaveForm("..."); SF.Show(); string JSONString = null; List <byte> UNTArray = null; List <byte> UNTHDArray = null; byte[] CollisionsArray = null; Thread JSONCreation = new Thread(() => { JSONString = CreateJSON(); }); JSONCreation.Start(); Thread UNTCreation = new Thread(() => { MakeUNTs(out UNTArray, out UNTHDArray); }); UNTCreation.Start(); Thread CollisionCreation = new Thread(() => { CollisionsArray = MakeCollisions(); }); CollisionCreation.Start(); SF.SetMessage("Creating NSBTXes..."); List <byte[]> NSBTXes = CreateNSBTXes(SF); using (var NewZippedTileset = File.Create(Filename)) { using (var ZipFile = new ZipArchive(NewZippedTileset, ZipArchiveMode.Create)) { SF.SetMessage("Saving NSBTX 1..."); ZipArchiveEntry Tex0File = ZipFile.CreateEntry(Textures[0]); using (BinaryWriter Wr = new BinaryWriter(Tex0File.Open())) { Wr.Write(NSBTXes[0]); } SF.SetMessage("Saving NSBTX 2..."); ZipArchiveEntry Tex1File = ZipFile.CreateEntry(Textures[1]); using (BinaryWriter Wr = new BinaryWriter(Tex1File.Open())) { Wr.Write(NSBTXes[1]); } SF.SetMessage("Saving NSBTX 3..."); ZipArchiveEntry Tex2File = ZipFile.CreateEntry(Textures[2]); using (BinaryWriter Wr = new BinaryWriter(Tex2File.Open())) { Wr.Write(NSBTXes[1]); } SF.SetMessage("Saving Texture..."); ZipArchiveEntry ImageFile = ZipFile.CreateEntry("texture.png"); using (MemoryStream ms = new MemoryStream()) { this.MainPNG.Save(ms, System.Drawing.Imaging.ImageFormat.Png); using (BinaryWriter Wr = new BinaryWriter(ImageFile.Open())) { byte[] PNG = ms.GetBuffer(); Wr.Write(PNG); } } CollisionCreation.Join(); SF.SetMessage("Saving collision..."); ZipArchiveEntry CollisionsFile = ZipFile.CreateEntry("collisions.chk"); using (BinaryWriter Wr = new BinaryWriter(CollisionsFile.Open())) { Wr.Write(CollisionsArray); } UNTCreation.Join(); SF.SetMessage("Saving Objects..."); ZipArchiveEntry UNTFile = ZipFile.CreateEntry("objects.unt"); using (BinaryWriter Wr = new BinaryWriter(UNTFile.Open())) { Wr.Write(UNTArray.ToArray <byte>()); } SF.SetMessage("Saving Object Headers..."); ZipArchiveEntry UNTHDFile = ZipFile.CreateEntry("objects.unthd"); using (BinaryWriter Wr = new BinaryWriter(UNTHDFile.Open())) { Wr.Write(UNTHDArray.ToArray <byte>()); } JSONCreation.Join(); SF.SetMessage("Saving JSON..."); ZipArchiveEntry JSONFile = ZipFile.CreateEntry("meta.json"); using (StreamWriter Wr = new StreamWriter(JSONFile.Open())) { Wr.Write(JSONString); } } } SF.Close(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Start: #region LoginRegion using (var autoForm = new LoginForm()) { if (autoForm.ShowDialog() != DialogResult.OK) { return; } } #endregion startChoice: #region CoustomMessageBox using (var question = new CustomMessageBox()) { var dialogResult = question.ShowDialog(); if (dialogResult == DialogResult.Yes) { result = dialogResult.ToString(); question.Close(); goto end; } else if (dialogResult == DialogResult.No) { result = dialogResult.ToString(); question.Close(); goto end; } else if (dialogResult == DialogResult.OK) { result = dialogResult.ToString(); question.Close(); goto end; } else if (dialogResult == DialogResult.Abort) { question.Close(); goto Start; } } #endregion end: #region EndRegion switch (result) { case "Yes": using (var habrPars = new HabrParserForm()) { if (habrPars.ShowDialog() == DialogResult.Cancel) { habrPars.Close(); goto startChoice; } } break; case "No": using (var agilityPars = new AgilityParserForm()) { if (agilityPars.ShowDialog() == DialogResult.Cancel) { agilityPars.Close(); goto startChoice; } } break; case "OK": using (var saveData = new SaveForm()) { if (saveData.ShowDialog() == DialogResult.Cancel) { saveData.Close(); goto startChoice; } } break; } #endregion }