public GameBrowser(ServerConnection connection, ChessCom.UserData userdata)
 {
     _connection = connection;
     _userdata   = userdata;
     InitializeComponent();
     Task.Run(() => {
         var matches = MatchesBind.FromChesscom(_connection.Call.AvailableGames(new ChessCom.Void()));
         Dispatcher.Invoke(() => this.dgMatchesDataGrid.ItemsSource = matches);
     });
 }
示例#2
0
        public static List <MatchesBind> FromChesscom(ChessCom.HostedGamesMap hostedGamesMap)
        {
            var matches = new List <MatchesBind>();

            foreach (var keyVal in hostedGamesMap.HostedGames)
            {
                var vr    = keyVal.Value.GameRules.VisionRules;
                var match = new MatchesBind
                {
                    _matchId       = keyVal.Value.Id,
                    Host           = keyVal.Value.Host.Username,
                    _hostUsertoken = keyVal.Value.Host.Usertoken,
                    HostElo        = keyVal.Value.Host.Elo,
                    ChessType      = keyVal.Value.GameRules.ChessType.ToString(),
                    SideType       = keyVal.Value.GameRules.SideType.ToString(),
                    Time           = TimeRulesToString(keyVal.Value.GameRules.TimeRules),
                    VisionRules    = !vr.Enabled?"No Vision Rules":vr.ViewMoveFields?"SlugChess Sea":"SlugChess Standard"
                };
                matches.Add(match);
            }

            return(matches);
        }