コード例 #1
0
        public void PrintResult(string strJsonProducts)
        {
            var products             = JsonConvertHelper.JsonDeserialize <string[]>(strJsonProducts);
            ProductsBusiness service = new ProductsBusiness();

            service.PrintResult(products);
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public async void LoadContent(long commentId)
        {
            string resJosn = await WebProvider.GetInstance().GetRequestDataAsync($"http://news-at.zhihu.com/api/4/comment/{commentId}/replies");

            if (resJosn != string.Empty)
            {
                NotificationReply = JsonConvertHelper.JsonDeserialize <NotificationReply>(resJosn);
            }
        }
コード例 #4
0
        public async void LoadContent()
        {
            string resJosn = await WebProvider.GetInstance().GetRequestDataAsync("http://news-at.zhihu.com/api/4/notifications");

            if (resJosn != string.Empty)
            {
                var jsonObj = Windows.Data.Json.JsonObject.Parse(resJosn);
                Notifications = JsonConvertHelper.JsonDeserialize <List <Notification> >(jsonObj["notifications"].ToString());
            }
        }
コード例 #5
0
        public void  AutoLogin()
        {
            string userInfoJson = AppSettings.Instance.UserInfoJson;

            if (userInfoJson != string.Empty)
            {
                UserInfo userInfo = JsonConvertHelper.JsonDeserialize <UserInfo>(userInfoJson);

                ViewModel.ViewModelLocator.AppShell.UserInfo = userInfo;
            }
        }
コード例 #6
0
        public AppShellViewModel(ICommonService <StartImage> startImageService, ICommonService <Themes> themesService)
        {
            _startImageService = startImageService;
            _themesService     = themesService;
            AppTheme           = AppSettings.Instance.CurrentTheme;
            Themes_Style       = new ObservableCollection <Theme_Style>();

            this.SplashInfo = JsonConvertHelper.JsonDeserialize <StartImage>(AppSettings.Instance.SplashInfo);

            this.LoadMainSource();

            this.ThemeItemClickCommand = new RelayCommand <Theme_Style>((e) =>
            {
                AppShell rootFrame = Window.Current.Content as AppShell;
                if (rootFrame != null)
                {
                    if (e.Id > 0)
                    {
                        rootFrame.AppFrame.Navigate(typeof(ThemePage), e.Id);
                    }
                    else
                    {
                        rootFrame.AppFrame.Navigate(typeof(HomePage));
                    }
                    Messenger.Default.Send <NotificationMessage>(new NotificationMessage("NotificationPanelClosed"));
                }
            });

            Messenger.Default.Register <NotificationMessage>(this, (msg) =>
            {
                switch (msg.Notification)
                {
                case "NotifyRefreshMenu":
                    this.LoadMainSource();
                    break;

                default:
                    break;
                }
            });

            System.Diagnostics.Debug.WriteLine("执行次数多了很蛋疼啊,,我说的是真的都是真的");
        }