private void KeyActive(object sender, EventArgs e) { while (input.isKeyAvailable()) { // Here should be the current view being rendered KeyEventArgs keyArgs = new KeyEventArgs(); TeacherInfoEventArgs teacherInfoEventArgs = new TeacherInfoEventArgs(); keyArgs.Cki = input.GetKey(); // Here diffrent methods will be attached to the event based on the Key // Triggered and deleted if needed // This is a pure logic for a controller -- into a method switch (keyArgs.Cki.Key) { case ConsoleKey.LeftArrow: case ConsoleKey.RightArrow: timer.KeyPress += taskbarController.ChangeSelect; timer.OnKeyPress(keyArgs); timer.KeyPress -= taskbarController.ChangeSelect; break; case ConsoleKey.I: timer.KeyPress += inputBoxController.ChangeState; timer.OnKeyPress(keyArgs); timer.KeyPress -= inputBoxController.ChangeState; break; case ConsoleKey.Enter: timer.KeyPress += inputBoxController.ChangeState; timer.OnKeyPress(keyArgs); timer.KeyPress -= inputBoxController.ChangeState; if (inputBoxController.GetInput(2) != null) { queryCreator.CreateQuery(inputBoxController.GetInput(2), taskbar.ReturnStateAsInt()); if (taskbar.ReturnStateAsInt() == 4) { teacherInfoEventArgs.Action = 1; } else { teacherInfoEventArgs.Action = 0; } teacherInfoEventArgs.Query = queryCreator.ReturnQuery(); teacherInfoEventArgs.RawInput = queryCreator.Input; timer.TeacherRequest += teacherDBController.TeacherRequestEventHandler; timer.OnTeacherRequest(teacherInfoEventArgs); timer.TeacherRequest -= teacherDBController.TeacherRequestEventHandler; } if (teacherInfoEventArgs.Action == 1 && queryCreator.ReturnQuery() != null) { outputBoxController1.FillOutputBox(teacherDBController.ReturnOperaionResult()); } else { outputBoxController2.FillOutputBox(teacherDBController.ReturnOperaionResult()); } inputBoxController.NullInput(); queryCreator.NullQeury(); teacherDBController.NullOperationResult(); break; case ConsoleKey.C: timer.KeyPress += outputBoxController1.ClearOutputBox; timer.KeyPress += outputBoxController2.ClearOutputBox; timer.OnKeyPress(keyArgs); timer.KeyPress -= outputBoxController1.ClearOutputBox; timer.KeyPress -= outputBoxController2.ClearOutputBox; break; case ConsoleKey.T: outputBoxController1.FillOutputBox(teacher.DisplayInfo()); break; } teacherView.Render(); System.Threading.Thread.Sleep(100); } }