示例#1
0
        private BulkSolveDataItem CreateGame()
        {
            if (DataContext is Data data)
            {
                UserDV selectedUser = data.UsersPanelDV.UserListDV.SelectedUser;
                if (selectedUser == null)
                {
                    return(null);
                }

                JsonConnectRequest request = new JsonConnectRequest();
                request.userToken = selectedUser.Token;
                JsonConnectResponse response = JsonCommunication.Connect(request);

                GameDV game = new GameDV();
                game.GameId    = response.gameId;
                game.GameToken = response.gameToken;
                if (!selectedUser.Games.Any(x => x.GameId == game.GameId))
                {
                    selectedUser.Games.Add(game);
                }


                BulkSolveDataItem bsdi = new BulkSolveDataItem();
                bsdi.DeskData            = new DeskData();
                bsdi.DeskData.SquareSize = 5;
                bsdi.Game = game;
                bsdi.User = selectedUser;

                return(bsdi);
            }
            return(null);
        }
示例#2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (DataContext is Data data)
            {
                UserDV selectedUser = data.UsersPanelDV.UserListDV.SelectedUser;
                if (selectedUser != null)
                {
                    JsonConnectRequest request = new JsonConnectRequest();
                    request.userToken = selectedUser.Token;
                    JsonConnectResponse response = JsonCommunication.Connect(request);

                    GameDV game = new GameDV();
                    game.GameId    = response.gameId;
                    game.GameToken = response.gameToken;
                    if (!selectedUser.Games.Any(x => x.GameId == game.GameId))
                    {
                        selectedUser.Games.Add(game);
                    }
                }
            }
        }