/// <inheritdoc /> public override void Dispose() { if (_preview != null) { _preview.Dispose(); _preview = null; } base.Dispose(); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode t = treeView1.SelectedNode; if (DisplayStyle == 0) { if (t.Parent == null || t.Name == "") { return; } preview?.Dispose(); preview = null; try { if (int.TryParse(t.Name, out int i)) { EntryStruct en = Entries[i]; if (!en.isDLC) { using (ME3Package pcc = MEPackageHandler.OpenME3Package(ME3Directory.cookedPath + en.Filename)) { if (en.isSkeletal) { SkeletalMesh skmesh = new SkeletalMesh(pcc, en.Index); // TODO: pass device preview = new ModelPreview(view.Device, skmesh, view.TextureCache); CenterView(); treeView2.Nodes.Clear(); if (previewWithTreeToolStripMenuItem.Checked) { treeView2.Visible = false; Application.DoEvents(); treeView2.Nodes.Add(skmesh.ToTree()); treeView2.Visible = true; } } else { } } } else { string loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec\\"; string dirDLC = ME3Directory.DLCPath; dirDLC += en.DLCName; dirDLC += "\\CookedPCConsole\\Default.sfar"; DLCUnpack dlc = new DLCUnpack(dirDLC); foreach (DLCUnpack.DLCEntry file in dlc.filesList) { try { string filename = Path.GetFileName(file.filenamePath); if (Path.GetExtension(filename).ToLower().EndsWith(".pcc") && filename == en.Filename) { using (Stream input = File.OpenRead(dirDLC), output = File.Create(loc + filename)) { dlc.ExtractEntry(file, input, output); } if (File.Exists(loc + filename)) { try { if (en.isSkeletal) { using (ME3Package pcc = MEPackageHandler.OpenME3Package(loc + filename)) { SkeletalMesh skmesh = new SkeletalMesh(pcc, en.Index); CenterView(); treeView2.Nodes.Clear(); if (previewWithTreeToolStripMenuItem.Checked) { treeView2.Visible = false; Application.DoEvents(); treeView2.Nodes.Add(skmesh.ToTree()); treeView2.Visible = true; } } } } catch (Exception) { } File.Delete(loc + filename); } } } catch (Exception) { } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }