public Controller(MyForm myForm, Game15 game15) { this.game15 = game15; this.myForm = myForm; myForm.KeyDown += MyForm_KeyDown; Application.Run(myForm); }
static void Main(string[] args) { Game15 game15 = new Game15(); MyForm myForm = new MyForm(); //ConsoleDraw consoleDraw = new ConsoleDraw(); //ConsoleController consoleController = new ConsoleController(game15, consoleDraw); Controller controller = new Controller(myForm, game15); }
private void MyForm_KeyDown(object sender, KeyEventArgs e) { MyForm myForm = sender as MyForm; Point point = myForm.Zero; game15.Move(ref point, e.KeyCode); myForm[point.X, point.Y].Text = ""; //switch (e.KeyCode) //{ // case Keys.Left: // if (myForm.Zero.Y - 1 >= 0) // { // myForm[myForm.Zero.X, myForm.Zero.Y].Text = myForm[myForm.Zero.X, myForm.Zero.Y-1].Text; // myForm[myForm.Zero.X, myForm.Zero.Y-1].Text = ""; // myForm.Zero = new Point (myForm.Zero.X, myForm.Zero.Y - 1); // } // break; // case Keys.Up: // if (myForm.Zero.X - 1 >= 0) // { // myForm[myForm.Zero.X, myForm.Zero.Y].Text = myForm[myForm.Zero.X-1, myForm.Zero.Y].Text; // myForm[myForm.Zero.X-1, myForm.Zero.Y].Text = ""; // myForm.Zero = new Point(myForm.Zero.X-1, myForm.Zero.Y); // } // break; // case Keys.Right: // if (myForm.Zero.Y + 1 < 4) // { // myForm[myForm.Zero.X, myForm.Zero.Y].Text = myForm[myForm.Zero.X, myForm.Zero.Y+1].Text; // myForm[myForm.Zero.X, myForm.Zero.Y+1].Text = ""; // myForm.Zero = new Point(myForm.Zero.X, myForm.Zero.Y + 1); // } // break; // case Keys.Down: // if (myForm.Zero.X + 1 < 4) // { // myForm[myForm.Zero.X, myForm.Zero.Y].Text = myForm[myForm.Zero.X+1, myForm.Zero.Y].Text; // myForm[myForm.Zero.X+1, myForm.Zero.Y].Text = ""; // myForm.Zero = new Point(myForm.Zero.X +1, myForm.Zero.Y); // } // break; // default: // break; //} }