Esempio n. 1
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            EmuApi.InitDll();
            bool showUpgradeMessage = UpdateHelper.PerformUpgrade();

            ConfigManager.Config.Video.ApplyConfig();
            EmuApi.InitializeEmu(ConfigManager.HomeFolder, Handle, ctrlRenderer.Handle, false, false, false);

            ConfigManager.Config.InitializeDefaults();
            ConfigManager.Config.ApplyConfig();

            _displayManager = new DisplayManager(this, ctrlRenderer, pnlRenderer, mnuMain, ctrlRecentGames);
            _displayManager.SetScaleBasedOnWindowSize();
            _shortcuts = new ShortcutHandler(_displayManager);

            _notifListener = new NotificationListener();
            _notifListener.OnNotification += OnNotificationReceived;

            _commandLine.LoadGameFromCommandLine();

            SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
            SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);
            BindShortcuts();

            Task.Run(() => {
                Thread.Sleep(25);
                this.BeginInvoke((Action)(() => {
                    ResizeRecentGames();
                    ctrlRecentGames.Initialize();

                    if (!EmuRunner.IsRunning())
                    {
                        ctrlRecentGames.Visible = true;
                    }
                }));
            });

            if (showUpgradeMessage)
            {
                MesenMsgBox.Show("UpgradeSuccess", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (ConfigManager.Config.Preferences.AutomaticallyCheckForUpdates)
            {
                UpdateHelper.CheckForUpdates(true);
            }

            InBackgroundHelper.StartBackgroundTimer();
            this.Resize += frmMain_Resize;
        }
Esempio n. 2
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            InBackgroundHelper.StopBackgroundTimer();

            if (_notifListener != null)
            {
                _notifListener.Dispose();
                _notifListener = null;
            }

            if (!_shuttingDown && Program.IsMono)
            {
                //This appears to prevent Mono from locking up when closing the form
                DebugApi.ResumeExecution();
                DebugWindowManager.CloseAll();

                Task.Run(() => {
                    EmuApi.Stop();
                    _shuttingDown = true;
                    this.BeginInvoke((Action)(() => this.Close()));
                });
                e.Cancel = true;
                return;
            }

            DebugApi.ResumeExecution();
            DebugWindowManager.CloseAll();

            ConfigManager.Config.WindowLocation = this.WindowState == FormWindowState.Normal ? this.Location : this.RestoreBounds.Location;
            ConfigManager.Config.WindowSize     = this.WindowState == FormWindowState.Normal ? this.Size : this.RestoreBounds.Size;
            ConfigManager.ApplyChanges();
            ConfigManager.SaveConfig();

            EmuApi.Stop();
            EmuApi.Release();
        }