예제 #1
0
        public HomePage_ViewModel(UserControl_HomePage homePage)
        {
            this._homePageView = homePage;
            this._myChat       = new UserControl_ChatControl(this.HomePageView.user);
            this._gameModeView = new UserControl_GameMode(this);

            this.ExtractChat        = new GeneralCommands <object>(Extract_Chat, CanExtractChat);
            this.LogOut             = new GeneralCommands <object>(Log_out, CanLogOut);
            this.Create             = new GeneralCommands <object>(CreateGame, CanCreateGame);
            this.CreateAssisted     = new GeneralCommands <object>(CreatGameAssisted, CanCreateGame);
            this.OpenGalleryCommand = new GeneralCommands <object>(OpenGallery, CanOpenGallery);
            this.ShowUserProfil     = new GeneralCommands <object>(Show_user_profil, Can_Show_Profil);
            this.UpdateUserProfil   = new GeneralCommands <object>(Show_update_user_profil, Can_Show_update_profil);
            this._homePageView.MyChat.Children.Add(_myChat);
            this._homePageView.MiddleView.Children.Add(_gameModeView);
            this.loggedOut = false;
            SocketService.MySocket.Off("disconnect");
            SocketService.MySocket.On("disconnect", () =>
            {
                _homePageView.Dispatcher.Invoke(() =>
                {
                    if (!loggedOut)
                    {
                        GameCreationFeedback_window a = new GameCreationFeedback_window("Connexion perdue", false);
                        a.ShowDialog();
                    }

                    SocketService.MySocket.Close();
                    SocketService.ResetSocket();
                    _homePageView.SwitchToLogin();
                });
            });
            getInfo();
        }
 public ChatWindow(HomePage_ViewModel home, UserControl_ChatControl chat)
 {
     InitializeComponent();
     this._home   = home;
     this._myChat = chat;
     this._home._homePageView.MyChat.Children.Remove(chat);
     this.MyChatWindow.Children.Add(chat);
     this.Show();
 }