コード例 #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)
                {
                    arcProv.Write(arcFile, Path.GetDirectoryName(filename), this.destFile, Path.GetFileName(filename));
                }
            }
        }
コード例 #2
0
ファイル: ExtractProgress.cs プロジェクト: s0da72/TQVaultAE
        /// <summary>
        /// Performs the extraction of an ARC file.
        /// </summary>
        private void DoArcExtraction()
        {
            try
            {
                bool canceled = false;

                foreach (string recordID in arcProv.GetKeyTable(MainForm.ARCFile))
                {
                    if (canceled)
                    {
                        break;
                    }

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

                    // Write the record
                    arcProv.Write(MainForm.ARCFile, this.BaseFolder, recordID, recordID);

                    // 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;
            }
        }