Exemple #1
0
        private void Connect(Loby selectedLoby)
        {
            LobyView      lobyView      = new LobyView();
            LobyViewModel lobyViewModel = new LobyViewModel(lobyView, selectedLoby, this);

            lobyView.DataContext = lobyViewModel;
            LobyViewModelProp    = lobyViewModel;

            Proxy.ConnectToLoby(selectedLoby, UserProp);

            MainWindowViewProp.Visibility = System.Windows.Visibility.Hidden;
            lobyView.ShowDialog();
            MainWindowViewProp.Visibility = System.Windows.Visibility.Visible;
        }
Exemple #2
0
        private void CreateLobyCommandExecute()
        {
            Loby loby = new Loby(_createLobyView.tbName.Text, _mainWindowViewModel.UserProp, _createLobyView.tbPass.Password);

            try
            {
                _mainWindowViewModel.Proxy.CreateLoby(loby);

                LobyView      lobyView      = new LobyView();
                LobyViewModel lobyViewModel = new LobyViewModel(lobyView, loby, _mainWindowViewModel);
                lobyView.DataContext = lobyViewModel;

                _mainWindowViewModel.LobyViewModelProp = lobyViewModel;

                _mainWindowViewModel.MainWindowViewProp.Visibility = System.Windows.Visibility.Hidden;
                _createLobyView.Close();
                lobyView.ShowDialog();
                _mainWindowViewModel.MainWindowViewProp.Visibility = System.Windows.Visibility.Visible;
            }
            catch
            {
                new MsgBox("Лобі з таким іменем вже існує").ShowDialog();
                _createLobyView.Close();
            }

            //if (_mainWindowViewModel.Proxy.CreateLoby(loby))
            //{
            //    LobyView lobyView = new LobyView();
            //    LobyViewModel lobyViewModel = new LobyViewModel(lobyView, loby, _mainWindowViewModel);
            //    lobyView.DataContext = lobyViewModel;

            //    _mainWindowViewModel.LobyViewModelProp = lobyViewModel;

            //    _mainWindowViewModel.MainWindowViewProp.Visibility = System.Windows.Visibility.Hidden;
            //    _createLobyView.Close();
            //    lobyView.ShowDialog();
            //    _mainWindowViewModel.MainWindowViewProp.Visibility = System.Windows.Visibility.Visible;
            //}
            //else
            //{
            //    new MsgBox("Лобі з таким іменем вже існує").ShowDialog();
            //    _createLobyView.Close();
            //}
        }