示例#1
0
        public void Run()
        {
            configuration = Configure();
            mainForm = CreateForm(configuration);
            mainFormState = mainForm.WindowState;

            bool formClosed = false;
            bool formResized = false;

            mainForm.MouseClick += OnMouseClick;
            mainForm.MouseMove += OnMouseMove;
            mainForm.KeyDown += OnKeyDown;
            mainForm.KeyUp += OnKeyUp;
            mainForm.Resize += (o, e) =>
            {
                if(mainForm.WindowState != mainFormState)
                {
                    OnResize(o, e);
                }
                mainFormState = mainForm.WindowState;
            };
            mainForm.ResizeBegin += (o, e) =>
            {
                formResized = true;
            };
            mainForm.ResizeEnd += (o, e) =>
            {
                formResized = false;
                OnResize(o, e);
            };
            mainForm.FormClosed += (o, e) =>
            {
                formClosed = true;
            };

            Initialize();
            LoadResources();

            clock.Start();
            MessagePump.Run(mainForm, () =>
            {
                if (formClosed)
                    return;

                Tick();
                if (!formResized)
                    Frame();
            });
            UnloadResources();
        }
示例#2
0
 protected virtual Form CreateForm(Configuration config)
 {
     return new RenderForm(config.WindowTitle)
     {
         ClientSize = new Size(config.WindowWidth, config.WindowHeight)
     };
 }