private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { try { if (ignoreonce) { ignoreonce = false; hideViewer(); } else { statusConsumer("Loading requested EBX..."); TreeNode t = treeView1.SelectedNode; if (t == null || t.Name == "") { return; } string sha1 = t.Name; byte[] data = Tools.GetDataBySHA1(sha1, GlobalStuff.getCatFile()); DAIEbx ebxFile = deserializeEbx(data); setEbxFile(ebxFile); statusConsumer("Done."); showViewer(); } } catch (Exception ex) { messageBoxOnException(ex); } }
private void exportAllButton_Click(object sender, EventArgs e) { FolderBrowserDialog d = new FolderBrowserDialog(); if (d.ShowDialog() == DialogResult.OK) { var entries = Database.LoadAllEbxEntries(); var stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i < entries.Count; i++) { var ebxEntry = entries[i]; var bytes = Tools.GetDataBySHA1(ebxEntry.sha1, GlobalStuff.getCatFile()); var daiEbx = new DAIEbx(); daiEbx.Serialize(new MemoryStream(bytes)); var ebxContainers = EbxDataContainers.fromDAIEbx(daiEbx, str => {}, false); var txt = ebxContainers.toText(); var outPath = Path.Combine(d.SelectedPath, $"{ebxEntry.path}_{ebxEntry.sha1.Substring(0, 8)}"); var dir = Path.GetDirectoryName(outPath); Directory.CreateDirectory(dir); File.WriteAllText(outPath, txt, Encoding.UTF8); if (i % 100 == 0) { Frontend.updateStatus($"Exported {i}/{entries.Count}, elapsec {stopwatch.ElapsedMilliseconds/1000}s"); } } Frontend.updateStatus("Finished export"); } }
private void toolStripButton1_Click(object sender, EventArgs e) { TreeNode t = treeView1.SelectedNode; if (t == null) { t = treeView1.Nodes[0]; } string search = toolStripTextBox1.Text; toolStripButton2.Visible = true; stop = false; while ((t = FindNext(t)) != null) { Application.DoEvents(); statusConsumer("Searching : " + GetPath(t) + "..."); if (stop) { statusConsumer("Search stopped."); toolStripButton2.Visible = false; return; } try { byte[] data = Tools.GetDataBySHA1(t.Name, GlobalStuff.getCatFile()); if (data.Length != 0) { DAIEbx ebxFile = deserializeEbx(data); string xml = ebxFile.ToXml(); if (xml.Contains(search)) { ignoreonce = true; treeView1.SelectedNode = t; showViewer(); setEbxFile(ebxFile); rawXmlViewer.search(search); statusConsumer("Match!"); toolStripButton2.Visible = false; return; } } } catch (Exception ex) { messageBoxOnException(ex); } } toolStripButton2.Visible = false; statusConsumer("Not found."); }