private async void join_Click(object sender, RoutedEventArgs e) { try { var picker = new FileOpenPicker(); picker.ViewMode = PickerViewMode.Thumbnail; picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); var filePickerResult = await picker.PickSingleFileAsync(); if (filePickerResult != null) { var bytes = (await FileIO.ReadBufferAsync(filePickerResult)).ToArray(); var proxy = new GameServiceProxy(new Uri("http://localhost:5000")); var game = await proxy.CreateGame("Mats"); game = await proxy.GetGame(game.Id); game = (await proxy.SubmitAnswer(game.Id, bytes)).Item2; } } catch (Exception ex) { } }
private void SendLoginRequest() { LoginResponse response = UserServiceProxy.Login(new LoginRequest { UserName = this.UserName, Password = this.Password }); ConsoleLog.Document += $" { response.IsSuccess } {response.Message} \n "; if (response.IsSuccess == true) { //save loged user authentication AuthenticatedUser.Authentication = response.Authentication; AuthenticatedUser.UserName = this.UserName; //update contactList ContactStateManager.AssignAllCurrentOnlineContacts(response.AllOtherUsers); //joining the chat service: JoinChatServiceResponse responseFromChatService = ChatServiceProxy.JoinService(new JoinChatServiceRequest()); ConsoleLog.Document += responseFromChatService.Message; //joining the Game Service: JoinGameServiceResponse responseFromGameService = GameServiceProxy.JoinService(new JoinGameServiceRequest()); ConsoleLog.Document += responseFromGameService.Message; UserServiceProxy.OnLoginEvent += UserServiceProxy_OnLoginEvent; ViewChanging("ContactListView"); //set online users to something : new class that will save online users } }
private void GameManager_OnGameChanged(object sender, OnInGameEventArgs e) { RefreshGameUI(); GameServiceProxy.InGame(new InGameRequest { UserOpponent = ChosenContact.UserName, SlotIdSource = e.SlotIdSource, SlotIdDestination = e.SlotIdDestination }); }
private void SendGameRequest() { if (ChosenContact != null) { GameResponse response = GameServiceProxy.Game(new GameRequest { UserOpponent = ChosenContact.UserName }); if (response.IsSuccess == true) //contact accepted invetion { Window gameWindow = GameWindowFactory.GetGameWindow(chosenContact.UserName); gameWindow.Show(); } ConsoleLog.Document = $" {response.IsSuccess} +\n {response.Message}"; } }
public LoginViewModel() { ConsoleLog = new ConsoleLog { Document = "check binding \n" }; //test AuthenticatedUser = AuthenticatedUser.Instance; //load all contacts: ContactStateManager.LoadAllContacts(); //init Proxies: UserServiceProxy = UserServiceProxy.Instance; ChatServiceProxy = ChatServiceProxy.Instance; GameServiceProxy = GameServiceProxy.Instance; //Init Commands: SendLoginRequestCommand = new MyCommand(SendLoginRequest); ChangeViewToSignUpCommand = new MyCommand(ChangeViewToSignUp); }
public GameWindowViewModel(IUserName chosenContact) { //get opponent: ChosenContact = chosenContact; //init Game: gameManager = new GameManager("hen", "simon"); gameManager.GameChanged += GameManager_OnGameChanged; gameManager.Game.StepsEnded += Game_OnStepsEnded; //init proxies: GameServiceProxy = GameServiceProxy.Instance; GameServiceProxy.OnInGameEvent += GameServiceProxy_OnInGame; //init UI Slots: RefreshGameUI(); cubesSteps = new ObservableCollection <Step>(gameManager.Game.Steps); ConsoleLog = new ConsoleLog(); //chosenSlotInit: onChosenSlotChanged += slotClicked; //init Commands: RollCubesCommand = new MyCommand(RollCubes); }
public StartViewModel(INavigationService navigationService, SnapFeudContext context) { _navigationService = navigationService; _gameProxy = new GameServiceProxy(context.WebApiBaseUri); Context = context; }