예제 #1
0
        public void AddComment(List <IOutboundAttachment> attachments, Action <bool> resultCallback, StickerItemData stickerItemData = null, string stickerReferrer = "")
        {
            string str1 = this.ucNewComment.TextBoxNewComment.Text;

            if (this.ReplyAutoForm != null && str1.StartsWith(this.ReplyAutoForm))
            {
                string str2 = this.ReplyAutoForm.Remove(this.ReplyAutoForm.IndexOf(", "));
                string str3 = this._replyToUid > 0L ? "id" : "club";
                long   num  = this._replyToUid > 0L ? this._replyToUid : -this.VM.OwnerId;
                str1 = str1.Remove(0, this.ReplyAutoForm.Length).Insert(0, string.Format("[{0}{1}|{2}], ", str3, num, str2));
            }
            string str4 = str1.Replace("\r\n", "\r").Replace("\r", "\r\n");

            if ((string.IsNullOrWhiteSpace(str4) || str4.Length < 2) && stickerItemData == null)
            {
                if (attachments.Count != 0)
                {
                    List <IOutboundAttachment>       outboundAttachmentList = attachments;
                    Func <IOutboundAttachment, bool> func1 = (Func <IOutboundAttachment, bool>)(a => a.UploadState != OutboundAttachmentUploadState.Completed);
                    if (!Enumerable.Any <IOutboundAttachment>(outboundAttachmentList, (Func <IOutboundAttachment, bool>)func1))
                    {
                        goto label_6;
                    }
                }
                // ISSUE: reference to a compiler-generated field
                resultCallback(false);
                return;
            }
label_6:
            if (str4.Length < 2 && attachments.Count <= 0 && stickerItemData == null)
            {
                return;
            }
            if (this._addingComment)
            {
                // ISSUE: reference to a compiler-generated field
                resultCallback(false);
            }
            else
            {
                this._addingComment = true;
                if (stickerItemData == null)
                {
                    this.ucNewComment.TextBoxNewComment.Text = string.Empty;
                }
                Comment comment1 = new Comment();
                comment1.cid          = 0L;
                comment1.date         = Extensions.DateTimeToUnixTimestamp(DateTime.UtcNow, true);
                comment1.text         = stickerItemData == null ? str4 : "";
                comment1.reply_to_cid = this._replyToCid;
                comment1.reply_to_uid = this._replyToUid;
                comment1.likes        = new Likes()
                {
                    can_like = 0
                };
                List <Attachment> m0List;
                if (stickerItemData != null)
                {
                    m0List = new List <Attachment>()
                    {
                        stickerItemData.CreateAttachment()
                    }
                }
                ;
                else
                {
                    m0List = Enumerable.ToList <Attachment>(Enumerable.Select <IOutboundAttachment, Attachment>(attachments, (Func <IOutboundAttachment, Attachment>)(a => a.GetAttachment())));
                }
                comment1.Attachments = ((List <Attachment>)m0List);
                int num = stickerItemData == null ? 0 : stickerItemData.StickerId;
                comment1.sticker_id = num;
                Comment comment2         = comment1;
                bool    fromGroupChecked = this.ucNewComment.FromGroupChecked;
                comment2.from_id = !fromGroupChecked ? AppGlobalStateManager.Current.LoggedInUserId : this.VM.OwnerId;
                this.VM.AddComment(comment2, attachments.Select <IOutboundAttachment, string>((Func <IOutboundAttachment, string>)(a => a.AttachmentId)).ToList <string>(), fromGroupChecked, (Action <bool, Comment>)((res, createdComment) =>
                {
                    if (res)
                    {
                        Execute.ExecuteOnUIThread((Action)(() =>
                        {
                            CommentItem commentItem = this.CreateCommentItem(createdComment);
                            this._addingComment = false;
                            MyVirtualizingPanel2 virtualizingPanel2 = this.virtPanel;
                            int count = this.virtPanel.VirtualizableItems.Count;
                            List <IVirtualizable> itemsToInsert = new List <IVirtualizable>();
                            itemsToInsert.Add((IVirtualizable)commentItem);
                            //int num = 0;
                            virtualizingPanel2.InsertRemoveItems(count, itemsToInsert, false, null);
                            this._runningCommentsCount = this._runningCommentsCount + 1;
                            this.KeepCommentsCountItemUpToDate();
                            this.ResetReplyFields();
                            resultCallback(true);
                            this.Panel.ScrollToBottom(true);
                        }));
                    }
                    else
                    {
                        Execute.ExecuteOnUIThread((Action)(() =>
                        {
                            GenericInfoUC.ShowBasedOnResult(1, "", null);
                            this._addingComment = false;
                            resultCallback(false);
                        }));
                    }
                }), stickerReferrer);
            }
        }
예제 #2
0
 public static void ShowBasedOnResult(int resultCode, string successString = "", VKRequestsDispatcher.Error error = null)
 {
     GenericInfoUC.ShowBasedOnResult((ResultCode)resultCode, successString, error);
 }