コード例 #1
0
 private void goToGameView(object obj)
 {
     if (LobbyViewModel != null)
     {
         LobbyViewModel.Dispose();
         LobbyViewModel = null;
     }
     Task.Delay(500).ContinueWith(_ =>
     {
         if (GameViewModel != null)
         {
             GameViewModel.Dispose();
             GameViewModel = null;
         }
         GameViewModel = new GameViewModel((string)obj);
         App.Current.Dispatcher.Invoke(delegate
         {
             SubChannels.Remove(_subChannels.SingleOrDefault(i => i.id == (Constants.LOBBY_CHANNEL + Lobbyname)));
             MessageChannel gameChannel = new MessageChannel(Constants.GAME_CHANNEL, true, false);
             if (!SubChannels.Contains(gameChannel))
             {
                 SubChannels.Add(gameChannel);
             }
             ChangeChannel(Constants.GAME_CHANNEL);
         });
         SwitchView = Views.Game;
         IsInGame   = true;
     });
 }
コード例 #2
0
        private void goToLobbyView(object lobbyData)
        {
            IsNotInLobby = false;
            Dictionary <string, string> data = new Dictionary <string, string>((Dictionary <string, string>)lobbyData);

            if (LobbyViewModel != null)
            {
                LobbyViewModel.Dispose();
                LobbyViewModel = null;
            }

            LobbyViewModel = new LobbyViewModel(data["lobbyName"], data["mode"]);
            this.Lobbyname = data["lobbyName"];
            string lobbyChannel = Constants.LOBBY_CHANNEL + this.Lobbyname;

            SwitchView = Views.Lobby;
            Application.Current.Dispatcher.Invoke(delegate
            {
                SubChannels.Add(new MessageChannel(lobbyChannel, true, true));
            });
            ChangeChannel(lobbyChannel);
        }
コード例 #3
0
        public void FetchChannels()
        {
            Application.Current.Dispatcher.Invoke(async delegate
            {
                SubChannels.Clear();
                NotSubChannels.Clear();

                try
                {
                    var subChannelReq    = await ServerService.instance.client.GetAsync(Constants.SERVER_PATH + Constants.SUB_CHANNELS_PATH + "/" + ServerService.instance.username);
                    var notSubChannelReq = await ServerService.instance.client.GetAsync(Constants.SERVER_PATH + Constants.NOT_SUB_CHANNELS_PATH + "/" + ServerService.instance.username);

                    ProcessChannelRequest(subChannelReq, SubChannels, true);
                    ProcessChannelRequest(notSubChannelReq, NotSubChannels, false);

                    ChangeChannel(Constants.DEFAULT_CHANNEL);
                    _subChannels.SingleOrDefault(i => i.id == Constants.DEFAULT_CHANNEL).isSelected = true;
                }
                catch (Exception e)
                {
                    ShowMessageBox(e.Message);
                }
            });
        }