示例#1
0
        /// <summary>
        /// Handler for clicking extract selected file.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">EventArgs data</param>
        private void SelectedFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.destFile) || fileType == CompressedFileType.Unknown)
            {
                return;
            }

            string         filename       = null;
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "TQ files (*.txt;*.dbr;*.tex;*.msh;*.anm;*.fnt;*.qst;*.pfx;*.ssh)|*.txt;*.dbr;*.tex;*.msh;*.anm;*.fnt;*.qst;*.pfx;*.ssh|All files (*.*)|*.*";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.Title            = "Save the Titan Quest File";
            string startPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "My Games"), "Titan Quest");

            saveFileDialog.InitialDirectory = startPath;
            saveFileDialog.FileName         = Path.GetFileName(this.destFile);

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                filename = saveFileDialog.FileName;
            }

            if (fileType == CompressedFileType.ArzFile)
            {
                DBRecordCollectionProvider.Write(this.record, Path.GetDirectoryName(filename), Path.GetFileName(filename));
            }
            else if (fileType == CompressedFileType.ArcFile)
            {
                arcFile.Write(Path.GetDirectoryName(filename), this.destFile, Path.GetFileName(filename));
            }
        }
示例#2
0
        /// <summary>
        /// Performs the extraction of an ARZ file.
        /// </summary>
        private void DoArzExtraction()
        {
            try
            {
                bool canceled = false;

                foreach (string recordID in Form1.ARZFile.GetKeyTable())
                {
                    if (canceled)
                    {
                        break;
                    }

                    // update label with recordID
                    this.recordIdBeingProcessed = recordID;
                    this.Invoke(new MethodInvoker(this.UpdateLabel));

                    // Write the record
                    var dbc = Form1.ARZFile.GetRecordNotCached(recordID);
                    DBRecordCollectionProvider.Write(dbc, this.baseFolder);

                    // Update progressbar
                    this.Invoke(new MethodInvoker(this.IncrementProgress));

                    // see if we need to cancel
                    Monitor.Enter(this);
                    canceled = this.cancel;
                    Monitor.Exit(this);
                }

                // notify complete.
                this.Invoke(new MethodInvoker(this.ExtractComplete));
            }
            catch (Exception err)
            {
                // notify failure
                this.exception = err;
                this.Invoke(new MethodInvoker(this.ExtractFailed));
                throw;
            }
        }