Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SinglePlayerViewModel"/> class.
 /// </summary>
 public SinglePlayerViewModel()
 {
     model      = new SingleClientModel();
     client     = model.Connect();
     model.Rows = Properties.Settings.Default.MazeRows;
     model.Cols = Properties.Settings.Default.MazeCols;
 }
Esempio n. 2
0
        /// <summary>
        /// Updates the ComboBox.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void UpdateComboBox(Object sender, EventArgs e)
        {
            try
            {
                //request from the server list of available games
                SingleClientModel model = new SingleClientModel();
                TcpClient client = model.Connect();
                string solve = (model.Communicate(client, "list"));
                var array = JArray.Parse(solve);
                JArray jarray = array;
                namesOfAvailableGames = jarray.ToObject<string[]>();
                List<string> stringsList = namesOfAvailableGames.OfType<string>().ToList();

                //add names of available games to the combo-box
                cboMazeNames.ItemsSource = stringsList;
            }
            catch (Exception)
            {
                MessageBox.Show("We didn't succeed to connect to the server",
                    "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                Dispatcher.Invoke(() =>
                {
                    Application.Current.Shutdown();
                });
            }

        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SinglePlayerGameWindow"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 public SinglePlayerGameWindow(SingleClientModel model)
 {
     spgVM = new SinglePlayerGameViewModel(model);
     spgVM.FinishGameHappend             += FinishGame;
     spgVM.SolveAnimationFinishedHappend += SolveMessege;
     DataContext = spgVM;
     InitializeComponent();
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SinglePlayerGameViewModel"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 public SinglePlayerGameViewModel(SingleClientModel model)
 {
     this.model             = model;
     model.PropertyChanged +=
         delegate(Object sender, PropertyChangedEventArgs e)
     {
         NotifyPropertyChanged("VM_" + e.PropertyName);
     };
 }