private void Window_KeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.F4: { if (!m_world.AnimationInProgress) { Application.Current.Shutdown(); } break; } case Key.E: { if (!m_world.AnimationInProgress) { if (m_world.RotationX >= -35) { m_world.RotationX -= 5.0f; } else { MessageBox.Show("Nije dozvoljeno ici ispod podloge!"); } } break; } case Key.D: { if (!m_world.AnimationInProgress) { if (m_world.RotationX <= 45) { m_world.RotationX += 5.0f; } else { MessageBox.Show("Nije dozvoljeno da podloga bude postavljena naopako!"); } } break; } case Key.S: { if (!m_world.AnimationInProgress) { m_world.RotationY -= 5.0f; } break; } case Key.F: { if (!m_world.AnimationInProgress) { m_world.RotationY += 5.0f; } break; } case Key.Add: { if (!m_world.AnimationInProgress) { m_world.SceneDistance -= 3.0f; } break; } case Key.Subtract: { if (!m_world.AnimationInProgress) { m_world.SceneDistance += 3.0f; } break; } case Key.V: { m_world.Animation(); break; } case Key.F2: OpenFileDialog opfModel = new OpenFileDialog(); bool result = (bool)opfModel.ShowDialog(); if (result) { try { World newWorld = new World(Directory.GetParent(opfModel.FileName).ToString(), Path.GetFileName(opfModel.FileName), (int)openGLControl.Width, (int)openGLControl.Height, openGLControl.OpenGL); m_world.Dispose(); m_world = newWorld; m_world.Initialize(openGLControl.OpenGL); } catch (Exception exp) { MessageBox.Show("Neuspesno kreirana instanca OpenGL sveta:\n" + exp.Message, "GRESKA", MessageBoxButton.OK); } } break; } }
private void Window_KeyDown(object sender, KeyEventArgs e) { //Stavka 11: U toku animacije onemoguciti interakciju sa korisnikom if (m_world.AnimationInProgress) { return; } else { this.okBtn.IsEnabled = true; this.scaleDarts_txt.IsEnabled = true; this.translateY.IsEnabled = true; this.txtRed.IsEnabled = true; this.txtGreen.IsEnabled = true; this.txtBlue.IsEnabled = true; switch (e.Key) { case Key.F5: this.Close(); break; case Key.T: m_world.RotationX -= 5.0f; break; case Key.G: m_world.RotationX += 5.0f; break; case Key.F: m_world.RotationY -= 5.0f; break; case Key.H: m_world.RotationY += 5.0f; break; case Key.Add: m_world.SceneDistance -= 50.0f; break; case Key.Subtract: m_world.SceneDistance += 50.0f; break; case Key.C: m_world.Animation(); this.okBtn.IsEnabled = false; this.scaleDarts_txt.IsEnabled = false; this.translateY.IsEnabled = false; this.txtRed.IsEnabled = false; this.txtGreen.IsEnabled = false; this.txtBlue.IsEnabled = false; break; case Key.V: m_world.Reset(); break; //Dodatno case Key.W: m_world.TranslateY -= 20.0f; break; case Key.S: m_world.TranslateY += 20.0f; break; case Key.A: m_world.TranslateX += 20.0f; break; case Key.D: m_world.TranslateX -= 20.0f; break; case Key.Z: m_world.SceneDistance += 20.0f; break; case Key.X: m_world.SceneDistance -= 20.0f; break; //case Key.Escape: break; //case Key.F2: // OpenFileDialog opfModel = new OpenFileDialog(); // bool result = (bool) opfModel.ShowDialog(); // if (result) // { // try // { // World newWorld = new World(Directory.GetParent(opfModel.FileName).ToString(), Path.GetFileName(opfModel.FileName), (int)openGLControl.Width, (int)openGLControl.Height, openGLControl.OpenGL); // m_world.Dispose(); // m_world = newWorld; // m_world.Initialize(openGLControl.OpenGL); // } // catch (Exception exp) // { // MessageBox.Show("Neuspesno kreirana instanca OpenGL sveta:\n" + exp.Message, "GRESKA", MessageBoxButton.OK ); // } // } // break; } } }