public void parseImage(WzImage image) { image.ParseImage(); deep++; makeRealDir(); string tempDir = currentDir; string tempDir2 = currentDirdunno; /* * Form1.Instance.BeginInvoke((MethodInvoker)delegate * { * Form1.Instance.progress.Maximum += image.WzProperties.Length; * }); * */ foreach (IWzImageProperty prop in image.WzProperties) { /* * Form1.Instance.BeginInvoke((MethodInvoker)delegate * { * Form1.Instance.progress.Value++; * }); * */ currentDir += prop.Name + "."; currentDirdunno += prop.Name + "."; parseProperties(prop, 1); currentDir = tempDir; currentDirdunno = tempDir2; } image.UnparseImage(); image.Dispose(); deep--; }
internal WzImage ParseXMLWzImg(XmlElement imgElement) { string name = imgElement.GetAttribute("name"); WzImage result = new WzImage(name); foreach (XmlElement subelement in imgElement) { result.WzProperties.Add(ParsePropertyFromXMLElement(subelement)); } result.Changed = true; if (this.useMemorySaving) { string path = Path.GetTempFileName(); WzBinaryWriter wzWriter = new WzBinaryWriter(File.Create(path), iv); result.SaveImage(wzWriter); wzWriter.Close(); result.Dispose(); result = imgDeserializer.WzImageFromIMGFile(path, iv, name); } return(result); }
private void SaveEtcData() { var dialog = new SaveFileDialog { FileName = "Commodity.img", Filter = Resources.FileSaveImgExt }; if (dialog.ShowDialog() != DialogResult.OK) { return; } if (File.Exists(dialog.FileName)) { try { File.Delete(dialog.FileName); } catch { MessageBox.Show($"Unable to delete the file located at {dialog.FileName}", Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } UpdateNodes(); var temp = Path.GetTempFileName(); using (var stream = File.Create(temp)) { using (var w = new WzBinaryWriter(stream, commodityImg.WzFileParent.MapleVersion, false)) { commodityImg.SaveImage(w); } } commodityImg.Dispose(); commodityImg = null; File.Move(temp, dialog.FileName); dialog.Dispose(); MessageBox.Show(Resources.MessageSuccess); ButtonLoad_Click(null, null); }
private void ButtonLoad_Click(object sender, EventArgs e) { var etcDataExists = Directory.Exists("Data\\Etc"); var etcWzExists = File.Exists("Etc.wz"); if (!etcDataExists && !etcWzExists) { MessageBox.Show(Resources.ErrorFileNotFound); return; } Wz.Etc.Dispose(); Wz.Character.Dispose(); Wz.Item.Dispose(); commodityImg?.Dispose(); commodityImg = null; ClearAllData(); if (etcDataExists && etcWzExists) { var result = MessageBox.Show(Resources.ErrorMultipleSources, Resources.ErrorMultipleSourcesTitle, MessageBoxButtons.YesNo); if (result == DialogResult.OK) { LoadFromImg(); } else { LoadFromWz(); } } else if (etcWzExists) { LoadFromWz(); } else { LoadFromImg(); } }
internal WzImage ParseXMLWzImg(XmlElement imgElement) { string name = imgElement.GetAttribute("name"); WzImage result = new WzImage(name); foreach (XmlElement subelement in imgElement) result.WzProperties.Add(ParsePropertyFromXMLElement(subelement)); result.Changed = true; if (this.useMemorySaving) { string path = Path.GetTempFileName(); WzBinaryWriter wzWriter = new WzBinaryWriter(File.Create(path), iv); result.SaveImage(wzWriter); wzWriter.Close(); result.Dispose(); result = imgDeserializer.WzImageFromIMGFile(path, iv, name); } return result; }
private void DumpXmlFromWzImage(string path) { var fName = Path.GetFileName(path); if (fName == null) { return; } FileStream fStream; WzImage img; try { fStream = File.Open(path, FileMode.Open); img = new WzImage(fName, fStream, SelectedVersion); img.ParseImage(); } catch (IOException ex) { MessageBox.Show("Unable to read file: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (ArgumentException) { MessageBox.Show("Please select a WZ Image File.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (UnauthorizedAccessException) { MessageBox.Show("Please re-run this program as an administrator to be able to dump files that are not in the OS drive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } catch (Exception) { MessageBox.Show("Please select a valid WZ Image File.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (img.WzProperties.Count() == 0) { img.Dispose(); fStream.Dispose(); MessageBox.Show("This image file contained no data when parsing. Please select a different Maple Version.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var open = new FolderBrowserDialog(); if (open.ShowDialog() != DialogResult.OK) { img.Dispose(); open.Dispose(); return; } var extractFolder = Path.Combine(open.SelectedPath, fName); if (File.Exists(extractFolder)) { extractFolder = GetValidFolderName(extractFolder, true); } if (Directory.Exists(extractFolder)) { var result = MessageBox.Show(extractFolder + " already exists.\r\nDo you want to overwrite that folder?\r\nNote: Clicking No will make a new folder.", "Folder Already Exists", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { return; } if (result != DialogResult.Yes) { extractFolder = GetValidFolderName(Path.Combine(open.SelectedPath, fName), false); } } if (!Directory.Exists(extractFolder)) { Directory.CreateDirectory(extractFolder); } DisableButtons(); Info.AppendText("Dumping data from " + fName + " to " + extractFolder + "...\r\n"); var startTime = DateTime.Now; CancelSource = new CancellationTokenSource(); string startingPath = new DirectoryInfo(extractFolder).Name; new WzXml(this, open.SelectedPath, startingPath, includePngMp3Box.Checked, SelectedLinkType).DumpImage(img, startingPath); open.Dispose(); img.Dispose(); fStream.Dispose(); CancelSource.Dispose(); var duration = DateTime.Now - startTime; UpdateTextBoxInfo(Info, "Finished dumping " + fName + " in " + GetDurationAsString(duration), true); UpdateToolstripStatus("Dumped " + fName + " successfully"); EnableButtons(); }