Example #1
0
        private void HandlePostBtnClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                var availableLen = GetAvailableStatusText();
                if (availableLen < 0)
                {
                    ShowMessage("Exceeds the status length limit. Try the post-as-pic option.", false);

                    IsPostAsPic = true;
                    return;
                }

                ClearMessage();

                if (!Validate())
                    return;

                if (null != Posting)
                {
                    var args = new PostingEventArgs();
                    args.PostingText = Text;

                    Posting(this, args);

                    if (!args.IsContinue)
                        return;
                }

                ShowMessage("Posting...");

                if (!this.IsPicAttached)
                {
                    var updateStatusInfo = new UpdateStatusInfo() { Status = Text, Latitude = 31.22f, Longitude = 121.48f };

                    AMicroblog.PostStatusAsync(
                        delegate(AsyncCallResult<StatusInfo> result)
                        {
                            if (result.Success)
                            {
                                var statusInfo = result.Data;
                                AddStatusToView(statusInfo);

                                ShowMessage("Message posted successfully at {0}", statusInfo.CreatedAt);
                            }
                            else
                                ShowMessage("Failed to post message due to: {0}", false, result.Exception.Message);

                            if (null != Posted)
                                Posted(this, null);

                        }, updateStatusInfo);
                }
                else
                {
                    try
                    {
                        var updStatusData = new UpdateStatusWithPicInfo();
                        updStatusData.Status = Text;
                        updStatusData.Pic = this.AttachedPicLocation;

                        var postCallback = new AsyncCallback<StatusInfo>(delegate(AsyncCallResult<StatusInfo> result)
                        {
                            if (result.Success)
                            {
                                var statusInfo = result.Data;

                                AddStatusToView(statusInfo);

                                this.AttachedPicLocation = string.Empty;

                                ShowMessage("Message posted successfully at {0}", statusInfo.CreatedAt);
                            }
                            else
                            {
                                this.IsPicAttached = true;
                                ShowMessage("Failed to post message due to: {0}", false, result.Exception.Message);
                            }
                        });

                        AMicroblog.PostStatusWithPicAsync(postCallback, updStatusData);
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message, false);
                    }
                }

                this.IsPicAttached = false;
                txbStatus.Clear();
            }
            catch (Exception ex)
            {
                ShowMessage(ex.Message, false);
            }
        }
Example #2
0
        private void HandlePosting(object sender, PostingEventArgs e)
        {
            if (mode == PosterMode.Forward)
            {
                DoForward(e.PostingText);

                if (ckbOption.IsChecked.HasValue && ckbOption.IsChecked.Value)
                    DoComment(e.PostingText);
                e.IsContinue = false;
            }
            else if (mode == PosterMode.Comment)
            {
                DoComment(e.PostingText);
                if (ckbOption.IsChecked.HasValue && ckbOption.IsChecked.Value)
                    DoForward(e.PostingText);
                e.IsContinue = false;
            }
            else if (mode == PosterMode.ReplyComment)
            {
                AMicroblog.ReplyComment(targetComment.ID, poster.Text, targetComment.Status.ID);
                viewModel.ShowMessage("Comments replied.");
            }
            else if (mode == PosterMode.Repost)
            {
                e.IsContinue = true;
            }

            this.Close();
        }