Example #1
0
        private IEnumerable <PakFileItem> EnumerateItems(TreeNode node)
        {
            PakFileItem item = node.Tag as PakFileItem;

            if (item != null)
            {
                yield return(item);
            }

            foreach (TreeNode n in node.Nodes)
            {
                foreach (PakFileItem i in EnumerateItems(n))
                {
                    yield return(i);
                }
            }
        }
Example #2
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            if (treeView.SelectedNode == null)
            {
                return;
            }
            PakFileItem item = treeView.SelectedNode.Tag as PakFileItem;

            if (item == null)
            {
                return;
            }

            string targetPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(item.Name));

            using (FileStream stream = new FileStream(targetPath, FileMode.Create))
            {
                byte[] content = reader.GetData(item);
                stream.Write(content, 0, content.Length);
            }

            Text = "Waiting for preview to close";
            ProcessStartInfo info = new ProcessStartInfo(targetPath);

            info.UseShellExecute = true;
            try
            {
                Process process = Process.Start(info);
                process.WaitForExit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, $"Unable to preview file:\n{targetPath}\n\n{ex.Message}", "Preview Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            File.Delete(targetPath);
            Text = $"{Path.GetFileName(filename)} - {TITLE}";
        }