Beispiel #1
0
 /// <summary>
 ///  Deja de ejecutar el ejemplo actual
 /// </summary>
 public void StopCurrentExample()
 {
     if (CurrentExample != null)
     {
         CurrentExample.Dispose();
         CurrentExample = null;
     }
 }
Beispiel #2
0
        private void Advance(double dt = TimeStep)
        {
            CurrentExample.ComputeExternalForces();

            kinematics.Integrate(dt);

            historyIndex++;
            StoreHistory();
        }
 public void ResetCurrentExample()
 {
     if (CurrentExampleIndex == -1)
     {
         NextExample();
     }
     else if (CurrentExample != null)
     {
         CurrentExample.Respawn();
     }
 }
Beispiel #4
0
        protected override void OnRedraw()
        {
            Display.Clear(Color.Gray);

            CurrentExample.Draw();

            Font.AgateMono.Size  = 16;
            Font.AgateMono.Style = FontStyles.Bold;

            Font.AgateMono.DrawText(0, 0, DebugInfo());
        }
 private void BeginCurrentExercise()
 {
     CurrentExample.enabled = true;
     if (CurrentExample.GetType().ToString() == "AllDone")
     {
         _exampleControlText.SetGradualText("That's it!");
     }
     else
     {
         _exampleControlText.SetGradualText("Current example:\n" + CurrentExample.ToString());
     }
 }
        private void tvExamples_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (CurrentExample == null)
            {
                exampleRenderer.Clear();
                return;
            }

            exampleRenderer.Example = CurrentExample;
            if (CurrentExample.AutoRun)
            {
                CurrentExample.RunExample();
            }
        }
Beispiel #7
0
 /// <summary>
 /// Se inicia el Render loop del ejemplo.
 /// </summary>
 public void InitRenderLoop()
 {
     while (ApplicationRunning)
     {
         //Renderizo si es que hay un ejemplo activo
         if (CurrentExample != null)
         {
             //Solo renderizamos si la aplicacion tiene foco, para no consumir recursos innecesarios
             if (Form.ApplicationActive())
             {
                 CurrentExample.Tick();
             }
             else
             {
                 //Si no tenemos el foco, dormir cada tanto para no consumir gran cantidad de CPU
                 Thread.Sleep(100);
             }
         }
         // Process application messages
         Application.DoEvents();
     }
 }
Beispiel #8
0
        private void Handler_KeyDown(object sender, AgateInputEventArgs e)
        {
            if (e.KeyCode == KeyCode.Escape)
            {
                AgateApp.Quit();
            }

            if (e.KeyCode == KeyCode.Z)
            {
                InitializeExample();
            }
            if (e.KeyCode == KeyCode.Space && !running)
            {
                Advance();
            }
            if (e.KeyCode == KeyCode.Space && running)
            {
                running = false;
            }
            if (e.KeyCode == KeyCode.Enter || e.KeyCode == KeyCode.Return)
            {
                running = !running;
            }

            if (e.KeyCode == KeyCode.NumPadPlus || e.KeyCode == KeyCode.Plus)
            {
                CurrentExample.AddParticle();
                InitializeExample();
            }
            if (e.KeyCode == KeyCode.NumPadMinus || e.KeyCode == KeyCode.Minus)
            {
                CurrentExample.RemoveParticle();
                InitializeExample();
            }
            if (e.KeyCode == KeyCode.Left)
            {
                debugParticleIndex--;
                if (debugParticleIndex < 0)
                {
                    debugParticleIndex = 0;
                }
            }
            if (e.KeyCode == KeyCode.Right)
            {
                debugParticleIndex++;
                if (debugParticleIndex >= system.Particles.Count)
                {
                    debugParticleIndex = system.Particles.Count - 1;
                }
            }
            if (e.KeyCode == KeyCode.Down)
            {
                historyIndex--;
                if (historyIndex < 0)
                {
                    historyIndex = 0;
                }

                LoadHistory();
            }
            if (e.KeyCode == KeyCode.Up)
            {
                historyIndex++;
                if (historyIndex >= history.Count)
                {
                    historyIndex = history.Count - 1;
                }

                LoadHistory();
            }
            if (e.KeyCode == KeyCode.PageDown)
            {
                exampleIndex++;
                if (exampleIndex >= examples.Count)
                {
                    exampleIndex = examples.Count - 1;
                }

                InitializeExample();
            }
            if (e.KeyCode == KeyCode.PageUp)
            {
                exampleIndex--;
                if (exampleIndex < 0)
                {
                    exampleIndex = 0;
                }

                InitializeExample();
            }

            if (e.KeyCode >= KeyCode.D1 && e.KeyCode <= KeyCode.D2)
            {
                debugInfoPage = (int)(e.KeyCode - KeyCode.D1);
            }

            if (e.KeyCode >= KeyCode.F1 && e.KeyCode <= KeyCode.F12)
            {
                solverIndex = (int)(e.KeyCode - KeyCode.F1) % solvers.Count;

                InitializeExample();
            }
        }