Пример #1
0
        private void SimForm_Paint(object sender, PaintEventArgs e)
        {
            using (Image image = Image.FromHbitmap(SimulatorAPI.GetSimulatorBitmap(this.simulator)))
            {
                e.Graphics.DrawImage(image, 0, 0);
                e.Graphics.DrawString("FPS: " + Math.Round(100000 / this.renderMilliseconds) / 100 + " (" + Math.Round(this.renderMilliseconds / 10) / 100 + " seconds)",
                                      this.Font, Brushes.Yellow, 5, 5);
                e.Graphics.DrawString("Mouse Dragging: Rotation",
                                      this.Font, Brushes.Yellow, 5, 20);

                for (int i = 0; i < this.renderers.Count; i++)
                {
                    string name     = this.renderers[i].Item1;
                    IntPtr renderer = this.renderers[i].Item2;

                    e.Graphics.DrawString("F" + (i + 1).ToString() + ": " + name,
                                          this.Font, (this.currentRenderer == renderer ? Brushes.Red : Brushes.White), 5, 40 + i * 15);
                }

                for (int i = 0; i < this.scenes.Count; i++)
                {
                    string name  = this.scenes[i].Item1;
                    IntPtr scene = this.scenes[i].Item2;

                    e.Graphics.DrawString((i + 1).ToString() + ": " + name,
                                          this.Font, (this.currentScene == scene ? Brushes.Blue : Brushes.White), 5, 45 + (this.renderers.Count + i) * 15);
                }

                e.Graphics.DrawString("A: Full Screen Anti-Alias",
                                      this.Font, Brushes.Yellow, 5, 50 + (this.renderers.Count + this.scenes.Count) * 15);
            }
        }
Пример #2
0
 private void SimForm_KeyUp(object sender, KeyEventArgs e)
 {
     if (this.debuggerIntersectPixel)
     {
         this.debuggerIntersectPixel = false;
         this.Cursor = Cursors.SizeAll;
     }
     if (!e.Control && !e.Shift && !e.Alt)
     {
         int code = (int)e.KeyCode;
         if ((int)Keys.F1 <= code && code < (int)Keys.F1 + this.renderers.Count)
         {
             this.currentRenderer = this.renderers[code - (int)Keys.F1].Item2;
             Render();
         }
         else if ((int)Keys.D1 <= code && code < (int)Keys.D1 + this.scenes.Count)
         {
             this.currentScene = this.scenes[code - (int)Keys.D1].Item2;
             Render();
         }
         else if ((int)Keys.NumPad1 <= code && code < (int)Keys.NumPad1 + this.scenes.Count)
         {
             this.currentScene = this.scenes[code - (int)Keys.NumPad1].Item2;
             Render();
         }
         else
         {
             switch (e.KeyCode)
             {
             case Keys.A:
                 if (this.currentRenderer != IntPtr.Zero)
                 {
                     SimulatorAPI.RenderScene(this.simulatorFSAA, this.currentScene, this.currentRenderer);
                     Bitmap bitmapFSAA = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
                     using (Graphics gFSAA = Graphics.FromImage(bitmapFSAA))
                         using (Image image = Image.FromHbitmap(SimulatorAPI.GetSimulatorBitmap(this.simulatorFSAA)))
                         {
                             gFSAA.DrawImage(image, 0, 0);
                         }
                     new ResultForm(bitmapFSAA).Show();
                 }
                 break;
             }
         }
     }
 }