Beispiel #1
0
        private async void btnChangeAvater_Tapped(object sender, TappedRoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker();

            picker.ViewMode = PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");

            // 选取单个文件
            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                var stream = await file.OpenSequentialReadAsync();

                await WebProvider.GetInstance().SendPostRequestAsync("http://news-at.zhihu.com/api/4/avatar", stream);

                string resJosn = await WebProvider.GetInstance().GetRequestDataAsync("http://news-at.zhihu.com/api/4/account");

                var UserInfo = JsonConvertHelper.JsonDeserialize <UserInfo>(resJosn);
                ViewModel.ViewModelLocator.AppShell.UserInfo.Avatar        = UserInfo.Avatar;
                ViewModel.ViewModelLocator.AppShell.UserInfo.Name          = UserInfo.Name;
                ViewModel.ViewModelLocator.AppShell.UserInfo.BoundServices = UserInfo.BoundServices;
                AppSettings.Instance.UserInfoJson = JsonConvertHelper.JsonSerializer(ViewModel.ViewModelLocator.AppShell.UserInfo);
            }
        }
Beispiel #2
0
        private async void tbEdit_Unchecked(object sender, RoutedEventArgs e)
        {
            string userName = tbUserName.Text.Trim();

            if (userName != string.Empty && userName != ViewModel.ViewModelLocator.AppShell.UserInfo.Name)
            {
                ViewModel.ViewModelLocator.AppShell.UserInfo.Name = userName;

                string postJosn = "{" + $"\"name\":\"{userName}\"" + "}";
                await WebProvider.GetInstance().SendPostRequestAsync("http://news-at.zhihu.com/api/4/name", postJosn, WebProvider.ContentType.ContentType3);

                AppSettings.Instance.UserInfoJson = JsonConvertHelper.JsonSerializer(ViewModel.ViewModelLocator.AppShell.UserInfo);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Load Splash
        /// </summary>
        public async Task UpdateSplashInfo()
        {
            if (NetWorkHelper.NetWrokState != 0)
            {
                var newSplash = await _startImageService.GetNotAvailableCacheObjAsync("start-image", "1080*1776");

                if (System.IO.Path.GetFileNameWithoutExtension(newSplash.Img) != System.IO.Path.GetFileNameWithoutExtension(this.SplashInfo.Img))
                {
                    DownloadHelper.SaveImage(newSplash.Img);
                    newSplash.Img = "ms-appdata:///local/" + System.IO.Path.GetFileName(newSplash.Img);
                    AppSettings.Instance.SplashInfo = JsonConvertHelper.JsonSerializer(newSplash);
                }
            }
        }
        private async void btnReply_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (AppSettings.Instance.UserInfoJson == string.Empty)
            {
                await new Functions().SinaLogin();
                if (AppSettings.Instance.UserInfoJson == string.Empty)
                {
                    return;
                }
            }
            Comment selectedComment = ((MenuFlyoutItem)sender).DataContext as Comment;

            Frame.Navigate(typeof(PostCommentPage), new[] { _viewModel.StoryId, JsonConvertHelper.JsonSerializer(selectedComment) });
        }