Esempio n. 1
0
 public SinglePlayerGame(ISinglePlayerViewModel vm, Window parent)
 {
     InitializeComponent();
     this.parent                  = parent;
     this.vm                      = vm;
     this.player.DataContext      = this.vm;
     this.KeyDown                += this.GameSurface_KeyDown;
     this.vm.OnGameStatusChanged += this.OnStatusChanged;
 }
 /// <summary>
 /// The constructor connects to the view model via events and initializes
 /// values
 /// </summary>
 /// <param name="vm"></param>
 public SingleMazeView(ISinglePlayerViewModel vm)
 {
     InitializeComponent();
     this.vm          = vm;
     this.DataContext = vm;
     this.KeyDown    += vm.HandleKey;
     vm.EndEvent     += MazeEndReached;
     vm.ServerError  += ServerError;
 }
        private void btn_startgame_Click(object sender, RoutedEventArgs e)
        {
            this.single_vm.MazeName    = this.game_properties.txt_gamename.Text;
            this.single_vm.MazeRowsStr = this.game_properties.txt_rows.Text;
            this.single_vm.MazeColsStr = this.game_properties.txt_cols.Text;


            ISinglePlayerViewModel vm = this.single_vm.StartGame();

            if (vm == null)
            {
                MessageBox.Show("Invalid input!");
                return;
            }

            Window next = new SinglePlayerGame(vm, this.parent);

            next.Show();
            this.parent = null;
            this.Close();
        }