예제 #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();
        }
예제 #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");
            }
        }
예제 #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");
            }
        }
예제 #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();
            });
        }
예제 #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
     });
 }
예제 #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();
        }
예제 #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
     });
 }
예제 #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
            });
        }
예제 #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
     });
 }
예제 #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
     });
 }
예제 #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);
        }
예제 #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();
 }
예제 #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);
        }
예제 #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();
        }
예제 #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);
        }
예제 #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
            });
        }
예제 #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();
        }
예제 #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();
            });
        }
예제 #19
0
 private void DownloadButton_Click(object sender, RoutedEventArgs e)
 {
     PopupMessage.DisplayMessageInRes("Inprogress");
 }