コード例 #1
0
        private async void ToServerAsync()
        {
            (string, string, string, bool)dataTuple;
            string resultCode        = "";
            string name              = "";
            string gender            = "";
            bool   isHavePastMessage = false;
            string login             = Login ?? "";
            string password          = new System.Net.NetworkCredential(string.Empty, Password).Password;
            await Task.Run(async() =>
            {
                try
                {
                    _serverWorker     = ServerWorker.NewInstance();
                    dataTuple         = await _serverWorker.AuthorizationAsync(login, GetHash(password));
                    resultCode        = dataTuple.Item1;
                    name              = dataTuple.Item2;
                    gender            = dataTuple.Item3;
                    isHavePastMessage = dataTuple.Item4;
                    if (resultCode == "28")
                    {
                        if (IsRemember)
                        {
                            await Task.Run(() => _logicDb.AddNewUser(login, password));
                        }
                        UserContainer.Login    = Login;
                        UserContainer.Password = Password;
                        UserContainer.Gender   = gender;
                    }
                    else
                    {
                        IsNotAuthorization = true;
                        await Task.Run(() => _logicDb.DeleteUser(login, password));
                    }
                }
                catch
                {
                    // ignore
                }
            });

            if (resultCode == "28")
            {
                MainChatPageViewModel mainChatPageViewModel = new MainChatPageViewModel(name);
                NewPage             = new MainChatPageView();
                NewPage.DataContext = mainChatPageViewModel;
                mainChatPageViewModel.StartLoad(isHavePastMessage);
                Login = "";
                _viewWindow.PasswordWrite("");
                IsRemember = false;
            }
            else if (resultCode == "")
            {
                ErrorDialogView errorDialogView = new ErrorDialogView(new ErrorDialogViewModel("Ошибка подключения к серверу!"));
                errorDialogView.ShowDialog();
            }
            IsCanClick = true;
        }
コード例 #2
0
 public GameRatingViewModel(string name)
 {
     _serverWorker    = ServerWorker.NewInstance();
     Condition        = "Visible";
     Name             = name;
     IsEnableOverall  = false;
     IsEnableUsers    = true;
     IsEnableComputer = true;
 }
コード例 #3
0
        public UsersPageViewModel(string name)
        {
            _serverWorker = ServerWorker.NewInstance();

            Condition   = "Visible";
            Name        = name;
            Users       = new ObservableCollection <UserViewModel>();
            _pastAction = "";
        }
コード例 #4
0
        public GamePlayViewModel(string name, string typoOfGame)
        {
            _serverWorker = ServerWorker.NewInstance();
            TypeOfGame    = typoOfGame;
            Condition     = "Visible";
            Name          = name;

            if (TypeOfGame == "With user")
            {
                IsVisibleGame    = false;
                IsVisibleSpinner = true;
                _delegateMove    = MoveForGameWithUserAsync;
            }
            else
            {
                IsVisibleGame     = true;
                IsVisibleSpinner  = false;
                OpponentName      = "Компьютер";
                _gameLogic        = new GameLogic(this);
                FirstGamerSymbol  = _gameLogic.GamerSymbol;
                SecondGamerSymbol = _gameLogic.ComputerSymbol;
                TextNotification  = $"Вы играете за {FirstGamerSymbol}";
                ShowNotificationAsync();
                if (FirstGamerSymbol == "X")
                {
                    GameInformation = FIRST_PLAYER_TURN;
                    IsEnable        = true;
                }
                else
                {
                    GameInformation = "Ожидание хода от компьютера";
                }
                _delegateMove = MoveForGameWithComputer;
            }
            IsVisibleCancel = false;

            OneOneSquare     = "";
            OneTwoSquare     = "";
            OneThreeSquare   = "";
            TwoOneSquare     = "";
            TwoTwoSquare     = "";
            TwoThreeSquare   = "";
            ThreeOneSquare   = "";
            ThreeTwoSquare   = "";
            ThreeThreeSquare = "";

            OneOneBack     = (Brush) new BrushConverter().ConvertFromString("Transparent");
            OneTwoBack     = (Brush) new BrushConverter().ConvertFromString("Transparent");
            OneThreeBack   = (Brush) new BrushConverter().ConvertFromString("Transparent");
            TwoOneBack     = (Brush) new BrushConverter().ConvertFromString("Transparent");
            TwoTwoBack     = (Brush) new BrushConverter().ConvertFromString("Transparent");
            TwoThreeBack   = (Brush) new BrushConverter().ConvertFromString("Transparent");
            ThreeOneBack   = (Brush) new BrushConverter().ConvertFromString("Transparent");
            ThreeTwoBack   = (Brush) new BrushConverter().ConvertFromString("Transparent");
            ThreeThreeBack = (Brush) new BrushConverter().ConvertFromString("Transparent");
        }
コード例 #5
0
        public MainChatPageViewModel(string name)
        {
            NotificationTranslator.CreateNotifier();
            NotificationTranslator.GetEnteringUserNotification($"Добро пожаловать, {name}!", "Success");

            Name          = name;
            _serverWorker = ServerWorker.NewInstance();

            Condition = "Visible";

            LoadEnable(true, true, false, true, true);
        }
コード例 #6
0
        public ChatViewModel(ChatView chatView, string name)
        {
            _chatView     = chatView;
            _serverWorker = ServerWorker.NewInstance();
            _cache        = new Cache(name);
            Name          = name;

            Condition               = "Visible";
            Index                   = 0;
            IsFocus                 = true;
            IsVisibleNotification   = false;
            IsVisibleButtonToBottom = false;
            CountNewMessages        = 0;

            _haveNewMessage           = false;
            _isGoToBottom             = false;
            _countClickButtonToBottom = 0;
        }
コード例 #7
0
 public SettingsPageViewModel(string name)
 {
     _serverWorker        = ServerWorker.NewInstance();
     _typesOfNotification = new List <string> {
         "All on", "Off about entering users", "Off about new messages", "All off"
     };
     _typesOfSound = new List <int>
     {
         NotificationTranslator.SOUND_OFF,
         NotificationTranslator.IPHONE,
         NotificationTranslator.VKONTAKTE,
         NotificationTranslator.TELEGRAM,
         NotificationTranslator.WHATS_UP_IPHONE,
         NotificationTranslator.WHATS_UP_ANDROID,
         NotificationTranslator.CLASSMATES,
         NotificationTranslator.ASKA
     };
     Condition = "Visible";
     Name      = name;
     IndexTypeOfNotification = _typesOfNotification.IndexOf(SettingsContainer.TypeOfNotification);
     IndexTypeOfSound        = _typesOfSound.IndexOf(SettingsContainer.TypeOfSoundAtNotificationNewMessage);
 }
コード例 #8
0
 public GameMainPageViewModel(string name)
 {
     _serverWorker = ServerWorker.NewInstance();
     Condition     = "Visible";
     Name          = name;
 }