Example #1
0
 public static FFTText ReadPSXIso(FileStream stream, BackgroundWorker worker)
 {
     return(FFTTextFactory.GetPsxText(stream, worker));
 }
Example #2
0
        private void LoadFile(LoadType loadType, string filename, Stream isoStream, Stream tblStream)
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.WorkerSupportsCancellation = true;
            worker.WorkerReportsProgress      = true;
            worker.DoWork +=
                delegate(object sender, DoWorkEventArgs args)
            {
                FFTText text = null;
                switch (loadType)
                {
                case LoadType.Open:
                    text = FFTTextFactory.GetFilesXml(filename, worker);
                    break;

                case LoadType.PspFilename:
                    text = FFTText.ReadPSPIso(filename, worker);
                    break;

                case LoadType.PsxFilename:
                    text = FFTText.ReadPSXIso(filename, worker);
                    break;

                case LoadType.PspStreamAndTable:
                    text = FFTTextFactory.GetPspText(isoStream, tblStream, worker);
                    break;

                case LoadType.PsxStreamAndTable:
                    text = FFTTextFactory.GetPsxText(isoStream, tblStream, worker);
                    break;
                }
                if (text == null || worker.CancellationPending)
                {
                    args.Cancel = true;
                    return;
                }

                LoadFile(text);
            };
            MethodInvoker enableForm =
                delegate()
            {
                fileMenuItem.Enabled = true;
                isoMenuItem.Enabled  = true;
                textMenuItem.Enabled = true;
                fileEditor1.Enabled  = true;
                helpMenuItem.Enabled = true;
                Cursor = Cursors.Default;
            };

            worker.RunWorkerCompleted +=
                delegate(object sender, RunWorkerCompletedEventArgs args)
            {
                if (args.Error != null)
                {
                    MessageBox.Show(this, "Error loading file: " + args.Error.Message, "Error", MessageBoxButtons.OK);
                }
                if (InvokeRequired)
                {
                    Invoke(enableForm);
                }
                else
                {
                    enableForm();
                }
            };

            fileMenuItem.Enabled = false;
            isoMenuItem.Enabled  = false;
            textMenuItem.Enabled = false;
            fileEditor1.Enabled  = false;
            helpMenuItem.Enabled = false;
            Cursor = Cursors.WaitCursor;
            worker.RunWorkerAsync();
        }