示例#1
0
        private void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
        {
            if (_allowAltF4 && e.Key == OpenTK.Input.Key.F4 && keys.Contains(Keys.LeftAlt))
            {
                window.Close();
                return;
            }
            Keys xnaKey = KeyboardUtil.ToXna(e.Key);

            if (!keys.Contains(xnaKey))
            {
                keys.Add(xnaKey);
            }
        }
示例#2
0
        public void Run()
        {
            Window = Factory.CreateWindow(640, 400, Program.AppName,
                                          GraphicsMode.Default, DisplayDevice.Default);
            Window.Visible = true;
            Drawer         = new GdiPlusDrawer2D();
            UpdateClientSize();

            Init();
            TryLoadTexturePack();
            platformDrawer.window = Window;
            platformDrawer.Init();

            Downloader = new AsyncDownloader(Drawer);
            Downloader.Init("");
            Downloader.Cookies   = new CookieContainer();
            Downloader.KeepAlive = true;

            fetcher = new ResourceFetcher();
            fetcher.CheckResourceExistence();
            checkTask = new UpdateCheckTask();
            checkTask.RunAsync(this);

            if (!fetcher.AllResourcesExist)
            {
                SetScreen(new ResourcesScreen(this));
            }
            else
            {
                SetScreen(new MainScreen(this));
            }

            while (true)
            {
                Window.ProcessEvents();
                if (!Window.Exists)
                {
                    break;
                }
                if (ShouldExit)
                {
                    if (Screen != null)
                    {
                        Screen.Dispose();
                        Screen = null;
                    }
                    break;
                }

                checkTask.Tick();
                Screen.Tick();
                if (Dirty)
                {
                    Display();
                }
                Thread.Sleep(10);
            }

            if (Options.Load())
            {
                LauncherSkin.SaveToOptions();
                Options.Save();
            }

            if (ShouldUpdate)
            {
                Updater.Applier.ApplyUpdate();
            }
            if (Window.Exists)
            {
                Window.Close();
            }
        }
示例#3
0
 /// <summary>
 /// Closes the NativeWindow.
 /// </summary>
 public void Close()
 {
     EnsureUndisposed();
     implementation.Close();
 }