예제 #1
0
        static void Main(string[] args)
        {
            BiffViewerOptions options = ParseCommandLine(args);

            if (options != null)
            {
                if (args.Length == 0)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainWindow());
                }
                else
                {
                    try
                    {
                        BiffViewer viewer = new BiffViewer(options);
                        viewer.DoTheMagic();
                    }
                    catch (CommandLineException cex)
                    {
                        Console.WriteLine(cex.Message);
                        PrintUsage();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("An unexpected error occurred.");
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
        }
예제 #2
0
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;

            BiffViewerOptions options = e.Argument as BiffViewerOptions;
            BiffViewer        viewer  = new BiffViewer(options);

            try
            {
                viewer.DoTheMagic(worker);
            }
            catch (IOException ex)
            {
                MessageBox.Show(ex.Message, "BiffView++", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                throw;
            }

            if (worker.CancellationPending)
            {
                e.Cancel = true;
            }
        }