Ejemplo n.º 1
0
        public void ZMachineThread(Object argsO)
        {
            String[] args = (String[])argsO;
            if (args.Length > 0 && args[0] == "last" && LastPlayedGames.Count > 0)
            {
                args[0] = LastPlayedGames[LastPlayedGames.Count - 1];
            }

            try
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    mnuInGame.Visibility = System.Windows.Visibility.Visible;
                    mnuMain.Visibility   = System.Windows.Visibility.Collapsed;
                    _screen.Focus();

                    if (Properties.Settings.Default.ShowDebugMenu == true)
                    {
                        miDebugInfo.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        miDebugInfo.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }));
                Frotz.os_.SetScreen((IZScreen)_screen);

                ZColorCheck.resetDefaults();

                _screen.GameSelected += new EventHandler <GameSelectedEventArgs>(_screen_GameSelected);
                Frotz.Generic.main.MainFunc((String[])args);

                Dispatcher.Invoke(new Action(delegate
                {
                    _screen.Reset();
                }));

                if (closeOnQuit)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        this.Close();
                    }));
                }
            }
            catch (ZMachineException)
            { // Noop
            }
            catch (ThreadAbortException)
            { // TODO It may be wise to handle this
            }
            catch (Exception ex)
            {
                MessageBox.Show("EX:" + ex);
            }
            finally
            {
                _screen.GameSelected -= new EventHandler <GameSelectedEventArgs>(_screen_GameSelected);
                Dispatcher.Invoke(new Action(delegate
                {
                    buildMainMenu();

                    mnuInGame.Visibility = System.Windows.Visibility.Collapsed;
                    mnuMain.Visibility   = System.Windows.Visibility.Visible;

                    this.Title = "FrotzNET";
                }));
            }
        }