Example #1
0
        public static void ExtractResourceFromTVNode(String BIFNameIn, TreeNode selNode, String pathContext, SaveFileDialog saveResourceDialog)
        {
            String             BIFname  = BIFNameIn;
            BIF_KEYTABLE_ENTRY nodeData = ((BIF_KEYTABLE_ENTRY)selNode.Tag);
            String             RESname  = nodeData.ResourceName;

            try
            {
                DialogResult dr = DialogResult.Abort;

                MemoryStream ms = BIF_DATA.getFileDataFromBIF(pathContext + BIFname, nodeData.ResourceID);

                if (saveResourceDialog != null)
                {
                    saveResourceDialog.FileName = BIF_Utility.makeNewResName(nodeData.ResourceName, nodeData.ResourceType);
                    dr = saveResourceDialog.ShowDialog();
                }

                if (saveResourceDialog == null || dr == System.Windows.Forms.DialogResult.OK)
                {
                    StreamWriter sw = new StreamWriter(new FileStream(BIF_Utility.makeNewResName(nodeData.ResourceName, nodeData.ResourceType), FileMode.Create));
                    ms.Position = 0;
                    BIF_Utility.StreamCopyTo(ms, sw.BaseStream);
                    sw.Close();
                }
            }
            catch (FileNotFoundException fnf_ee)
            {
                MessageBox.Show("There was a problem retreiving the file from the BIF archive: \r\n"
                                + fnf_ee.Message + "\r\nHint: Voice localization files for The Witcher DLC (e.g. M1_3_00.bif ) are stored in the voices subdirectory.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ee)
            {
                MessageBox.Show("There was a problem retreiving the file from the BIF archive: \r\n"
                                + ee.Message + "",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeNode selNode = BIFTreeView.SelectedNode;

            if (selNode != null && selNode.Parent != null)
            {
                String             BIFname  = selNode.Parent.Text;
                BIF_KEYTABLE_ENTRY nodeData = ((BIF_KEYTABLE_ENTRY)selNode.Tag);
                String             RESname  = nodeData.ResourceName;

                try
                {
                    MemoryStream ms = BIF_DATA.getFileDataFromBIF(pathContext + BIFname, nodeData.ResourceID);

                    saveResourceDialog.FileName = BIF_Utility.makeNewResName(nodeData.ResourceName, nodeData.ResourceType);
                    DialogResult dr = saveResourceDialog.ShowDialog();

                    if (dr == System.Windows.Forms.DialogResult.OK)
                    {
                        StreamWriter sw = new StreamWriter(new FileStream(saveResourceDialog.FileName, FileMode.Create));
                        ms.Position = 0;
                        BIF_Utility.StreamCopyTo(ms, sw.BaseStream);
                        sw.Close();
                    }
                }
                catch (FileNotFoundException fnf_ee)
                {
                    MessageBox.Show("There was a problem retreiving the file from the BIF archive: \r\n"
                                    + fnf_ee.Message + "\r\nHint: Voice localization files for The Witcher DLC (e.g. M1_3_00.bif ) are stored in the voices subdirectory.",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ee)
                {
                    MessageBox.Show("There was a problem extracting the selected file: \r\n"
                                    + ee.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }