Esempio n. 1
0
        public JokePanelControl(JokeAPI jokeAPI, User userInfo = null)
        {
            this.InitializeComponent();

            JokeVM = new JokeViewModel(jokeAPI, userInfo);
            this.DataContext = JokeVM;
        }
Esempio n. 2
0
        public JokeViewModel(JokeAPI jokeAPI, User userInfo)
        {
            JokeAPI = jokeAPI;
            UserInfo = userInfo;

            _PageIndex = 1;
            Title = HashMap.JokeTitleMap[jokeAPI];
            LoadJokeInfoCollection(jokeAPI);
        }
Esempio n. 3
0
        private void LoadJokeInfoCollection(JokeAPI jokeAPI)
        {
            JokeInfoCollection = new IncrementalLoadingCollection<JokeInfo>(
               async (pageIndex, requestCount) =>
               {
                   IsBusy = !IsDisConnected;
                   PageIndex = pageIndex;
                   JokeResponse<JokeInfo> tempJokeResponse = await JokeAPIUtils.GetJokeInfoList<JokeInfo>(new RequestParam
                   {
                       jokeAPI = jokeAPI,
                       page = pageIndex,
                       count = requestCount,
                       token = JokeAPIUtils.UserLoginInfo.token,
                       args = UserInfo == null ? null : new string[] { UserInfo.id }
                   });
                   IsBusy = false;

                   return tempJokeResponse;
               },
               (jokeInfo) =>
               {
                   return JokeInfoCollection.FirstOrDefault(joke => joke.id == jokeInfo.id) != null;
               });

            _JokeInfoCollection.OnLoadStatusChanged += _JokeInfoCollection_OnLoadStatusChanged;
            _JokeInfoCollection.OnNetworkStatusChanged += _JokeInfoCollection_OnNetworkStatusChanged;
        }