private void listView1_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { CASCFolder folder = fileList.Tag as CASCFolder; if (folder == null) { return; } if (e.ItemIndex < 0 || e.ItemIndex >= folder.SubEntries.Count) { return; } ICASCEntry entry = folder.SubEntries.ElementAt(e.ItemIndex).Value; var flags = LocaleFlags.None; if (entry is CASCFile) { var rootInfos = cascHandler.GetRootInfo(entry.Hash); if (rootInfos == null) { throw new Exception("root entry missing!"); } foreach (var rootInfo in rootInfos) { flags |= rootInfo.Block.Flags; } } var item = new ListViewItem(new string[] { entry.Name, entry is CASCFolder ? "Folder" : "File", flags.ToString() }); item.ImageIndex = entry is CASCFolder ? 0 : 2; e.Item = item; }
private void ExtractFile(CASCFile file) { if (backgroundWorker1.CancellationPending) { throw new OperationCanceledException(); } backgroundWorker1.ReportProgress((int)((float)++NumExtracted / (float)NumFiles * 100)); var rootInfos = cascHandler.GetRootInfo(file.Hash); if (rootInfos == null) { return; } foreach (var rootInfo in rootInfos) { // only enUS atm if ((rootInfo.Block.Flags & locale) == 0) { continue; } var encInfo = cascHandler.GetEncodingInfo(rootInfo.MD5); if (encInfo == null) { continue; } foreach (var key in encInfo.Keys) { cascHandler.ExtractFile(key, ExtractPath, file.FullName); return; } } }