Ejemplo n.º 1
0
        private async void PostToCirclePage_Loaded(object sender, RoutedEventArgs arg)
        {
            LoadingIcon.Display();
            OwnCircles = await DataRequester.GetOwnCircles();

            if (OwnCircles.Circles != null && OwnCircles.Circles.Count > 0)
            {
                CurrentCircle            = OwnCircles.Circles[0];
                CurrentCircleBtn.Content = CurrentCircle.Name;
                OwnCircles.Circles.ForEach(circle => {
                    var menuItem = new MenuFlyoutItem()
                    {
                        Text = circle.Name, Tag = circle
                    };
                    menuItem.Click += (s, e) => { CurrentCircle = ((OwnCircleInfo)((MenuFlyoutItem)s).Tag); CurrentCircleBtn.Content = CurrentCircle.Name; };
                    CircleMenu.Items.Add(menuItem);
                });
            }
            else if (_needCreateCircle)
            {
                LLQNotifier.Default.Notify(new StoryEvent()
                {
                    Type = StoryEventType.CreateCircle
                });
                PopupMessage.DisplayMessageInRes("NoCircle");
            }
            LoadingIcon.Hide();
        }
Ejemplo n.º 2
0
        private async void ShareWeiBo(object sender, RoutedEventArgs e)
        {
            if (VM == null || VM.MainHtmlContent == null)
            {
                return;
            }

            Animator.Use(AnimationType.ZoomOutUp).SetDuration(TimeSpan.FromMilliseconds(800)).PlayOn(WeiboSharePopup, () =>
            {
                WeiboSharePopup.IsOpen  = false;
                var transform           = (CompositeTransform)AnimUtil.PrepareTransform(WeiboSharePopup, typeof(CompositeTransform));
                transform.CenterX       = transform.CenterY = 0;
                transform.ScaleX        = transform.ScaleY = 1;
                transform.TranslateX    = transform.TranslateY = 0;
                WeiboSharePopup.Opacity = 1;
            });

            WeiboSDKForWinRT.SdkNetEngine engine = new WeiboSDKForWinRT.SdkNetEngine();
            var response = await engine.RequestCmd(WeiboSDKForWinRT.SdkRequestType.POST_MESSAGE, new WeiboSDKForWinRT.CmdPostMessage()
            {
                Status = PostMsg.Text
            });

            if (response.errCode == WeiboSDKForWinRT.SdkErrCode.SUCCESS)
            {
                PopupMessage.DisplayMessageInRes("ShareSuccess");
            }
            else
            {
                PopupMessage.DisplayMessageInRes("ShareFailed");
            }
        }
Ejemplo n.º 3
0
        public async void JoinCircle()
        {
            if (!AuthorizationHelper.IsLogin)
            {
                PopupMessage.DisplayMessageInRes("NeedLogin");
                return;
            }

            if (Misc.ZhiHuCircleId.ToString() == CircleId && JoinCircleButtonIcon == _checkIcon)
            {
                PopupMessage.DisplayMessageInRes("CannotQuitZhiHuCircle");
                return;
            }

            if (JoinCircleButtonIcon == _addIcon)
            {
                JoinCircleButtonIcon = _checkIcon;
                await DataRequester.JoinCircle(CircleId);

                PopupMessage.DisplayMessageInRes("JoinCircleSuccess");
            }
            else
            {
                JoinCircleButtonIcon = _addIcon;
                await DataRequester.QuitCircle(CircleId);

                PopupMessage.DisplayMessageInRes("QuitCircleSuccess");
            }
        }
Ejemplo n.º 4
0
        private void OnWeiBoLogin(object sender, RoutedEventArgs e)
        {
            Hide();
            LoadingIcon.Display();
            AuthorizationHelper.Login(LoginType.Sina, null, loginSuccess =>
            {
                if (loginSuccess)
                {
                    PopupMessage.DisplayMessageInRes("LoginSuccess");
                    var info = StorageInfo.Instance.ZhiHuAuthoInfo;
                    if (info == null)
                    {
                        return;
                    }

                    LLQNotifier.Default.Notify(new LoginEvent()
                    {
                        IsLogin = true, UserPhotoUrl = info.avatar
                    });
                }
                else
                {
                    PopupMessage.DisplayMessageInRes("LoginFailed");
                }
                LoadingIcon.Hide();
            });
        }
Ejemplo n.º 5
0
 private void CreateCircle_Click(object sender, RoutedEventArgs e)
 {
     if (!AuthorizationHelper.IsLogin)
     {
         PopupMessage.DisplayMessageInRes("NeedLogin");
         return;
     }
     LLQNotifier.Default.Notify(new StoryEvent()
     {
         Type = StoryEventType.CreateCircle
     });
 }
Ejemplo n.º 6
0
        private void MyFav_Click(object sender, RoutedEventArgs e)
        {
            if (!AuthorizationHelper.IsLogin)
            {
                PopupMessage.DisplayMessageInRes("NeedLogin");
                return;
            }

            VM.CurrentCategoryId = Misc.Favorite_Category_Id;
            VM.CategoryName      = string.Format(StringUtil.GetString("FavCategoryName"), 0);
            MainListView.SetRefresh(true);
            ResetCategoryPanel();
        }
Ejemplo n.º 7
0
 private void ShareToWeiBo(object sender, RoutedEventArgs e)
 {
     if (!AuthorizationHelper.IsLogin)
     {
         PopupMessage.DisplayMessageInRes("NeedLogin");
         Animator.Use(AnimationType.Shake).PlayOn(ShareButton);
         return;
     }
     LLQNotifier.Default.Notify(new StoryEvent()
     {
         Type = StoryEventType.ShareToWeiBo
     });
 }
Ejemplo n.º 8
0
        private void DelComment(object sender, RoutedEventArgs e)
        {
            if (!AuthorizationHelper.IsLogin)
            {
                PopupMessage.DisplayMessageInRes("NeedLogin");
                Animator.Use(AnimationType.Shake).PlayOn(CommentDel);
                return;
            }

            Animator.Use(AnimationType.TakingOff).PlayOn(CommentReply);
            LLQNotifier.Default.Notify(new CommentEvent()
            {
                Type = CommentEventType.Delete, Comment = (Comment)DataContext
            });
        }
Ejemplo n.º 9
0
 private void FavStatusChanged(object sender, ToggleEventArgs e)
 {
     if (!AuthorizationHelper.IsLogin)
     {
         PopupMessage.DisplayMessageInRes("NeedLogin");
         Animator.Use(AnimationType.Shake).PlayOn(FavButton);
         e.IsCancel = true;
         return;
     }
     Animator.Use(AnimationType.Bounce).PlayOn(FavButton);
     LLQNotifier.Default.Notify(new StoryEvent()
     {
         Type = StoryEventType.Fav, IsChecked = e.IsChecked
     });
 }
Ejemplo n.º 10
0
 private void LikeStatusChanged(object sender, ToggleEventArgs e)
 {
     if (!AuthorizationHelper.IsLogin)
     {
         PopupMessage.DisplayMessageInRes("NeedLogin");
         Animator.Use(AnimationType.Shake).PlayOn(LikeButton);
         e.IsCancel = true;
         return;
     }
     LikeCount = (int.Parse(LikeCount) + (e.IsChecked ? 1 : -1)).ToString();
     Animator.Use(AnimationType.StandUp).PlayOn(LikeButton);
     LLQNotifier.Default.Notify(new StoryEvent()
     {
         Type = StoryEventType.Like, IsChecked = e.IsChecked
     });
 }
Ejemplo n.º 11
0
        private async void SendComment()
        {
            if (!AuthorizationHelper.IsLogin)
            {
                PopupMessage.DisplayMessageInRes("NeedLogin");
                return;
            }

            if (string.IsNullOrEmpty(VM.CommentContent))
            {
                return;
            }

            await VM.SendComment();

            VM.CommentContent = "";
            CommentListView.SetRefresh(true);
        }
Ejemplo n.º 12
0
 private void Login(object sender, RoutedEventArgs e)
 {
     VM.UserName = StringUtil.GetString("Logining");
     AuthorizationHelper.Login(LoginType.Sina, (isSuccess, msg) =>
     {
         if (isSuccess)
         {
             VM.LoginSuccess();
             PopupMessage.DisplayMessageInRes("LoginSuccess");
         }
         else
         {
             PopupMessage.DisplayMessageInRes("LoginFailed");
             VM.UserName = StringUtil.GetString("PleaseLogin");
         }
     });
     ResetCategoryPanel();
 }
Ejemplo n.º 13
0
        private async Task <bool> CheckCaptcha(string captcha)
        {
            var captchaChecked = await DataRequester.CheckCaptcha(captcha);

            if (captchaChecked != null && captchaChecked.Success)
            {
                return(true);
            }

            if (captchaChecked != null && captchaChecked.Error != null && !string.IsNullOrEmpty(captchaChecked.Error.Message))
            {
                PopupMessage.DisplayMessage(captchaChecked.Error.Message);
            }
            else
            {
                PopupMessage.DisplayMessageInRes("CaptchaCheckFailed");
            }

            return(false);
        }
Ejemplo n.º 14
0
        private async void CreateCircle(object sender, RoutedEventArgs arg)
        {
            var title = CircleTitle.Text;
            var desc  = CircleDesc.Text;

            if (string.IsNullOrEmpty(title))
            {
                PopupMessage.DisplayMessageInRes("CreateCircleError");
                return;
            }

            var rst = await DataRequester.CreateCircle(title, desc);

            if (rst.Id < 1)
            {
                PopupMessage.DisplayMessage(rst.Error_Msg);
                return;
            }

            PopupMessage.DisplayMessageInRes("CreateCircleSuccess");
            NavigationManager.Instance.GoBack();
        }
Ejemplo n.º 15
0
        private bool CheckError(ErrorBase error)
        {
            if (error == null)
            {
                PopupMessage.DisplayMessageInRes("LoginFailed");
                return(false);
            }
            if (error.Error != null)
            {
                if (string.IsNullOrEmpty(error.Error.Message))
                {
                    PopupMessage.DisplayMessageInRes("LoginFailed");
                }
                else
                {
                    PopupMessage.DisplayMessage(error.Error.Message);
                }

                return(false);
            }

            return(true);
        }
Ejemplo n.º 16
0
        private void LikeComment(object sender, ToggleEventArgs e)
        {
            if (IsOwner)
            {
                e.IsCancel = true;
                return;
            }

            if (!AuthorizationHelper.IsLogin)
            {
                PopupMessage.DisplayMessageInRes("NeedLogin");
                Animator.Use(AnimationType.Shake).PlayOn(CommentLike);
                e.IsCancel = true;
                return;
            }

            CommentLikeCount = CommentLikeCount + (e.IsChecked ? 1 : -1);
            Animator.Use(AnimationType.StandUp).PlayOn(CommentLike);
            LLQNotifier.Default.Notify(new CommentEvent()
            {
                Type = CommentEventType.Like, Comment = (Comment)DataContext, IsLike = e.IsChecked
            });
        }
Ejemplo n.º 17
0
        private async void PostStory(object sender, RoutedEventArgs arg)
        {
            var title  = StoryTitle.Text;
            var url    = StoryUrl.Text;
            var reason = StoryReason.Text;

            if (CurrentCircle == null)
            {
                PopupMessage.DisplayMessageInRes("PostToCircleNeedCircle");
                return;
            }

            if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(title))
            {
                PopupMessage.DisplayMessageInRes("PostToCircleError");
                return;
            }

            await DataRequester.PostToCircle(url, title, reason, new List <int>() { CurrentCircle.Id });

            PopupMessage.DisplayMessageInRes("PostToCircleSuccess");
            NavigationManager.Instance.GoBack();
        }
Ejemplo n.º 18
0
        private void OnLogin(object sender, RoutedEventArgs e)
        {
            var userName = UserNameTxt.Text.Trim();

            userName = StringUtil.CheckPhoneNum(userName) ? "+86" + userName : userName;
            var password = PasswordTxt.Password.Trim();
            var captcha  = CaptchaTxt.Text.Trim();

            LoadingIcon.Display();
            AuthorizationHelper.Login(LoginType.ZhiHu, new ZhiHuLoginInfo()
            {
                Captcha = NeedCaptcha ? captcha : null, UserName = userName, Password = password
            }, loginSuccess =>
            {
                if (loginSuccess)
                {
                    PopupMessage.DisplayMessageInRes("LoginSuccess");
                    var info = StorageInfo.Instance.ZhiHuAuthoInfo;
                    if (info == null)
                    {
                        return;
                    }

                    LLQNotifier.Default.Notify(new LoginEvent()
                    {
                        IsLogin = true, UserPhotoUrl = info.avatar
                    });
                    Hide();
                }
                else
                {
                    GetCaptchaImage();
                }
                LoadingIcon.Hide();
            });
        }
Ejemplo n.º 19
0
 private void DownloadButton_Click(object sender, RoutedEventArgs e)
 {
     PopupMessage.DisplayMessageInRes("Inprogress");
 }