Exemplo n.º 1
0
 public void Dispose()
 {
     if (SpotlightViewModel != null)
     {
         SpotlightViewModel.Dispose();
     }
     if (GameSystemsViewModel != null)
     {
         GameSystemsViewModel.Dispose();
     }
     if (GenresViewModel != null)
     {
         GenresViewModel.Dispose();
     }
     if (YearsViewModel != null)
     {
         YearsViewModel.Dispose();
     }
     if (MultiPlayerViewModel != null)
     {
         MultiPlayerViewModel.Dispose();
     }
     if (RecentlyPlayedViewModel != null)
     {
         RecentlyPlayedViewModel.Dispose();
     }
     DisposeMainViewCancellationTokenSource(true);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPlayerGameWindow"/> class.
 /// </summary>
 /// <param name="mpVM">The mp vm.</param>
 public MultiPlayerGameWindow(MultiPlayerViewModel mpVM)
 {
     this.mpVM        = mpVM;
     this.DataContext = mpVM;
     //subscribe to events about the communication
     mpVM.FinishGameHappened += FinishGame;
     mpVM.Model.CommunicationProblemEvent += NotifyAboutCommunicationProblem;
     InitializeComponent();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPlayerMenu"/> class.
 /// </summary>
 public MultiPlayerMenu()
 {
     InitializeComponent();
     vm = new MultiPlayerViewModel(new MultiPlayerModel());
     this.DataContext     = vm;
     UserControl.TxtRows  = Properties.Settings.Default.MazeRows;
     UserControl.TxtCols  = Properties.Settings.Default.MazeCols;
     GameList.ItemsSource = vm.ListOfGames;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MultiPlayerView"/> class.
        /// </summary>
        /// <param name="spvm">The SPVM.</param>
        public MultiPlayerView(MultiPlayerViewModel spvm)
        {
            InitializeComponent();
            vm                           = spvm;
            DataContext                  = vm;
            MazeControl.DataContext      = vm;
            OtherMazeControl.DataContext = vm;
            closeWin                     = false;

            vm.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e) {
                if (e.PropertyName == "mazeGenerated")
                {
                    MazeControl.DrawMazeBoard();
                    OtherMazeControl.DrawMazeBoard();
                }
            };

            vm.PropertyChanged += delegate(Object sender, PropertyChangedEventArgs e) {
                if ((e.PropertyName != "otherPlayerLeaved" && e.PropertyName != "loseMaze" && e.PropertyName != "wonMaze" && e.PropertyName != "lostConnection") || closeWin == true)
                {
                    return;
                }

                string message;
                string windowName;

                if (e.PropertyName == "otherPlayerLeaved")
                {
                    closeWin   = true;
                    message    = "Other player leaved";
                    windowName = "Other leaved window";
                }
                else if (e.PropertyName == "loseMaze")
                {
                    message    = "YOU LOSER !!!";
                    windowName = "Lose Window";
                }
                else if (e.PropertyName == "wonMaze")
                {
                    message    = "YOU WON !!!";
                    windowName = "Won Window";
                }
                else
                {
                    message    = "Lost connection";
                    windowName = "Lost connection Window";
                }

                this.Dispatcher.Invoke(() => {
                    MessageBox.Show(this, message, windowName, MessageBoxButton.OK);
                    MainWindow win = new MainWindow();
                    win.Show();
                    this.Close();
                });
            };
            vm.Initialize(Properties.Settings.Default.ServerIP, Properties.Settings.Default.ServerPort);
        }
Exemplo n.º 5
0
        public MultiPlayerWindow()
        {
            InitializeComponent();
            vm = new MultiPlayerViewModel(MultiPlayerModel.Instance);
            this.DataContext = vm;
            UpateComobox();


            //lbUsers.ItemsSource = users;
        }
Exemplo n.º 6
0
        private void LoadMultiPlayerViewModel(GamesView view)
        {
            MultiPlayerVisibility = view.MultiPlayerItems.Count > 0 ? Visibility.Visible : Visibility.Collapsed;

            var images = view.MultiPlayerItems.Take(1).Select(i => ApiClient.GetImageUrl(i.Id, new ImageOptions
            {
                ImageType            = i.ImageType,
                Tag                  = i.ImageTag,
                Width                = Convert.ToInt32(TileWidth * 2),
                EnableImageEnhancers = false
            }));

            MultiPlayerViewModel.AddImages(images);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MultiPlayer"/> class.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="main">The main.</param>
        public MultiPlayer(IMultiPlayerModel model, Window main)
        {
            InitializeComponent();

            this.player = new MusicPlayer("multiplayer.mp3");
            this.player.Play();

            this.mainWindow  = main;
            this.model       = model;
            this.vm          = new MultiPlayerViewModel(this.model);
            this.DataContext = this.vm;
            this.mazeCtrlPlayer.DataContext   = this.vm.Player;
            this.mazeCtrlOpponent.DataContext = this.vm.Opponent;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPlayerWindow"/> class.
 /// </summary>
 public MultiPlayerWindow()
 {
     //create mpvm
     mpVM = new MultiPlayerViewModel();
     //subscribe to communicationProblems event
     mpVM.Model.CommunicationProblemEvent += NotifyAboutCommunicationProblem;
     mpVM.Rows = Properties.Settings.Default.MazeRows;
     mpVM.Cols = Properties.Settings.Default.MazeCols;
     this.DataContext = mpVM;
     wa = new WaitingAlertWindow();
     InitializeComponent();
     
     cboMazeNames.DropDownOpened += UpdateComboBox;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiMaze"/> class.
 /// </summary>
 /// <param name="vm">The vm.</param>
 public MultiMaze(MultiPlayerViewModel vm)
 {
     this.vm          = vm;
     this.DataContext = vm;
     InitializeComponent();
 }
Exemplo n.º 10
0
 public MultiPlayerWindowGame(MultiPlayerViewModel newVm)
 {
     InitializeComponent();
     this.vm          = newVm;
     this.DataContext = vm;
 }
 /// <summary>
 /// Handles the Click event of the btnRefresh control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void btnRefresh_Click(object sender, RoutedEventArgs e)
 {
     InitializeComponent();
     vm = new MultiPlayerViewModel();
     this.DataContext = vm;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiPlayerWindow"/> class.
 /// </summary>
 public MultiPlayerWindow()
 {
     InitializeComponent();
     vm = new MultiPlayerViewModel();
     this.DataContext = vm;
 }