public IEnumerable <StickersAutoSuggestItem> GetAutoSuggestItemsFor(string text)
        {
            if (!AppGlobalStateManager.Current.GlobalState.StickersAutoSuggestEnabled || string.IsNullOrWhiteSpace(text) || (text.Length > StickersAutoSuggestDictionary.MAX_TEXT_LENGTH || this._isRestoringState) || !this._isLoaded)
            {
                return((IEnumerable <StickersAutoSuggestItem>)Enumerable.Empty <StickersAutoSuggestItem>());
            }
            List <StickersAutoSuggestItem> stickersAutoSuggestItemList = new List <StickersAutoSuggestItem>();
            StickerKeywordItem             stickerKeywordItem;

            if (this._lookupDictionary.TryGetValue(text, out stickerKeywordItem))
            {
                List <int> .Enumerator enumerator1 = this.SortBasedOnRecents(stickerKeywordItem.user_stickers).GetEnumerator();
                try
                {
                    while (enumerator1.MoveNext())
                    {
                        int             current         = enumerator1.Current;
                        StickerItemData stickerItemData = new StickerItemData();
                        stickerItemData.StickerId = current;
                        string pathForStickerId128 = StickersDownloader.Instance.GetLocalPathForStickerId128(this._keywordsData.base_url, current);
                        stickerItemData.LocalPath = pathForStickerId128;
                        string pathForStickerId256 = StickersDownloader.Instance.GetLocalPathForStickerId256(this._keywordsData.base_url, current);
                        stickerItemData.LocalPathBig = pathForStickerId256;
                        string pathForStickerId512 = StickersDownloader.Instance.GetLocalPathForStickerId512(this._keywordsData.base_url, current);
                        stickerItemData.LocalPathExtraBig = pathForStickerId512;
                        StickerItemData stickerData = stickerItemData;
                        stickersAutoSuggestItemList.Add(new StickersAutoSuggestItem(stickerData, false));
                    }
                }
                finally
                {
                    enumerator1.Dispose();
                }
                List <int> .Enumerator enumerator2 = stickerKeywordItem.promoted_stickers.GetEnumerator();
                try
                {
                    while (enumerator2.MoveNext())
                    {
                        int             current         = enumerator2.Current;
                        StickerItemData stickerItemData = new StickerItemData();
                        stickerItemData.StickerId = current;
                        string pathForStickerId128 = StickersDownloader.Instance.GetLocalPathForStickerId128(this._keywordsData.base_url, current);
                        stickerItemData.LocalPath = pathForStickerId128;
                        string pathForStickerId256 = StickersDownloader.Instance.GetLocalPathForStickerId256(this._keywordsData.base_url, current);
                        stickerItemData.LocalPathBig = pathForStickerId256;
                        string pathForStickerId512 = StickersDownloader.Instance.GetLocalPathForStickerId512(this._keywordsData.base_url, current);
                        stickerItemData.LocalPathExtraBig = pathForStickerId512;
                        StickerItemData stickerData = stickerItemData;
                        stickersAutoSuggestItemList.Add(new StickersAutoSuggestItem(stickerData, true));
                    }
                }
                finally
                {
                    enumerator2.Dispose();
                }
            }
            return((IEnumerable <StickersAutoSuggestItem>)Enumerable.Take <StickersAutoSuggestItem>(stickersAutoSuggestItemList, StickersAutoSuggestDictionary.MAX_SUGGEST_STICKERS_COUNT));
        }
Ejemplo n.º 2
0
        public IEnumerable <StickersAutoSuggestItem> GetAutoSuggestItemsFor(string text)
        {
            if (!AppGlobalStateManager.Current.GlobalState.StickersAutoSuggestEnabled || string.IsNullOrWhiteSpace(text) || (text.Length > StickersAutoSuggestDictionary.MAX_TEXT_LENGTH || this._isRestoringState) || !this._isLoaded)
            {
                return(Enumerable.Empty <StickersAutoSuggestItem>());
            }
            List <StickersAutoSuggestItem> source = new List <StickersAutoSuggestItem>();
            StickerKeywordItem             stickerKeywordItem;

            if (this._lookupDictionary.TryGetValue(text, out stickerKeywordItem))
            {
                foreach (int sortBasedOnRecent in this.SortBasedOnRecents(stickerKeywordItem.user_stickers))
                {
                    StickerItemData stickerItemData = new StickerItemData();
                    stickerItemData.StickerId = sortBasedOnRecent;
                    string pathForStickerId128 = StickersDownloader.Instance.GetLocalPathForStickerId128(this._keywordsData.base_url, sortBasedOnRecent);
                    stickerItemData.LocalPath = pathForStickerId128;
                    string pathForStickerId256 = StickersDownloader.Instance.GetLocalPathForStickerId256(this._keywordsData.base_url, sortBasedOnRecent);
                    stickerItemData.LocalPathBig = pathForStickerId256;
                    string pathForStickerId512 = StickersDownloader.Instance.GetLocalPathForStickerId512(this._keywordsData.base_url, sortBasedOnRecent);
                    stickerItemData.LocalPathExtraBig = pathForStickerId512;
                    StickerItemData stickerData = stickerItemData;
                    source.Add(new StickersAutoSuggestItem(stickerData, false));
                }
                foreach (int promotedSticker in stickerKeywordItem.promoted_stickers)
                {
                    StickerItemData stickerItemData = new StickerItemData();
                    stickerItemData.StickerId = promotedSticker;
                    string pathForStickerId128 = StickersDownloader.Instance.GetLocalPathForStickerId128(this._keywordsData.base_url, promotedSticker);
                    stickerItemData.LocalPath = pathForStickerId128;
                    string pathForStickerId256 = StickersDownloader.Instance.GetLocalPathForStickerId256(this._keywordsData.base_url, promotedSticker);
                    stickerItemData.LocalPathBig = pathForStickerId256;
                    string pathForStickerId512 = StickersDownloader.Instance.GetLocalPathForStickerId512(this._keywordsData.base_url, promotedSticker);
                    stickerItemData.LocalPathExtraBig = pathForStickerId512;
                    StickerItemData stickerData = stickerItemData;
                    source.Add(new StickersAutoSuggestItem(stickerData, true));
                }
            }
            return(source.Take <StickersAutoSuggestItem>(StickersAutoSuggestDictionary.MAX_SUGGEST_STICKERS_COUNT));
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
 public StickersAutoSuggestItem(StickerItemData stickerData, bool isPromoted)
 {
     this._stickerData = stickerData;
     this._isPromoted  = isPromoted;
 }
Ejemplo n.º 5
0
        private void DoSend()
        {
            SendMessageRequest sendMessageRequest = new SendMessageRequest();
            int num1 = this._isChat ? 1 : 0;

            sendMessageRequest.IsChat = num1 != 0;
            long userOrChatId = this._userOrChatId;

            sendMessageRequest.UserOrCharId = userOrChatId;
            string messageText = this._messageText;

            sendMessageRequest.MessageBody = messageText;
            StickerItemData stickerItem = this.StickerItem;
            int             num2        = stickerItem != null ? stickerItem.StickerId : 0;

            sendMessageRequest.StickerId = num2;
            string stickerReferrer = this.StickerReferrer;

            sendMessageRequest.StickerReferrer = stickerReferrer;
            SendMessageRequest request = sendMessageRequest;

            if (this.GraffitiAttachmentItem != null && this.GraffitiAttachmentItem.IsUploaded)
            {
                request.AttachmentIds = new List <string>()
                {
                    this.GraffitiAttachmentItem.AttachmentId
                }
            }
            ;
            else if (this.Attachments.Count > 0)
            {
                request.AttachmentIds = new List <string>();
                foreach (IOutboundAttachment outboundAttachment in this.Attachments.Where <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => !a.IsGeo)))
                {
                    request.AttachmentIds.Add(outboundAttachment.AttachmentId);
                }
            }
            OutboundGeoAttachment outboundGeoAttachment = this.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a.IsGeo)) as OutboundGeoAttachment;

            if (outboundGeoAttachment != null)
            {
                request.Latitude      = outboundGeoAttachment.Latitude;
                request.Longitude     = outboundGeoAttachment.Longitude;
                request.IsGeoAttached = true;
            }
            OutboundForwardedMessages forwardedMessages = this.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a is OutboundForwardedMessages)) as OutboundForwardedMessages;

            if (forwardedMessages != null)
            {
                request.ForwardedMessagesIds = new List <int>(forwardedMessages.Messages.Select <Message, int>((Func <Message, int>)(m => m.mid)));
            }
            // ISSUE: reference to a compiler-generated field
            if (this.UploadFinished != null)
            {
                // ISSUE: reference to a compiler-generated field
                this.UploadFinished((object)this, EventArgs.Empty);
            }
            MessagesService.Instance.SendMessage(request, (Action <BackendResult <VKClient.Audio.Base.ResponseWithId, ResultCode> >)(res =>
            {
                if (res.ResultCode == ResultCode.Succeeded)
                {
                    this._deliveredMessageId = res.ResultData.response;
                    this._deliveryDateTime   = DateTime.UtcNow;
                    Logger.Instance.Info("OutboundMessageViewModel deliveryId = " + (object)this._deliveredMessageId);
                    this.OutboundMessageStatus = OutboundMessageStatus.Delivered;
                }
                else
                {
                    this.OutboundMessageStatus = OutboundMessageStatus.Failed;
                }
                // ISSUE: reference to a compiler-generated field
                if (this.MessageSent == null)
                {
                    return;
                }
                // ISSUE: reference to a compiler-generated field
                this.MessageSent((object)this, EventArgs.Empty);
            }));
        }
Ejemplo n.º 6
0
 public void PostComment(string text, long replyCid, long replyUid, bool fromGroup, List <IOutboundAttachment> attachments, Action <bool> callback, StickerItemData stickerItemData = null, string stickerReferrer = "")
 {
     if (!this.CanPostComment(text, attachments, stickerItemData))
     {
         callback(false);
     }
     else if (this._postingComment)
     {
         callback(false);
     }
     else
     {
         this._postingComment = true;
         this.SetInProgress(true, "");
         WallService.Current.AddComment(this._postId, this._ownerId, text, replyCid, fromGroup, attachments.Select <IOutboundAttachment, string>((Func <IOutboundAttachment, string>)(a => a.AttachmentId)).ToList <string>(), (Action <BackendResult <Comment, ResultCode> >)(res =>
         {
             this.SetInProgress(false, "");
             this._postingComment = false;
             Execute.ExecuteOnUIThread((Action)(() =>
             {
                 bool flag = res.ResultCode == ResultCode.Succeeded;
                 if (flag)
                 {
                     CommentItem commentItem = this.CreateCommentItem(res.ResultData);
                     this._runningCountOfComments = this._runningCountOfComments + 1;
                     this.UpdateCommentsCountItem();
                     MyVirtualizingPanel2 virtualizingPanel2 = this._panel;
                     int count = this._panel.VirtualizableItems.Count;
                     List <IVirtualizable> itemsToInsert = new List <IVirtualizable>();
                     itemsToInsert.Add((IVirtualizable)commentItem);
                     int num = 0;
                     object local = null;
                     virtualizingPanel2.InsertRemoveItems(count, itemsToInsert, num != 0, (IVirtualizable)local);
                     this._fetchedComments.Add(res.ResultData);
                     EventAggregator current = EventAggregator.Current;
                     WallCommentIsAddedDeleted commentIsAddedDeleted = new WallCommentIsAddedDeleted();
                     commentIsAddedDeleted.Added = true;
                     long toId = this._wallPostData.WallPost.to_id;
                     commentIsAddedDeleted.OwnerId = toId;
                     long id = this._wallPostData.WallPost.id;
                     commentIsAddedDeleted.WallPostId = id;
                     current.Publish((object)commentIsAddedDeleted);
                 }
                 callback(flag);
             }));
         }), stickerItemData == null ? 0 : stickerItemData.StickerId, stickerReferrer);
     }
 }
Ejemplo n.º 7
0
        public bool CanPostComment(string text, List <IOutboundAttachment> attachments, StickerItemData stickerItemData = null)
        {
            if ((string.IsNullOrWhiteSpace(text) || text.Length < 2) && stickerItemData == null)
            {
                if (attachments.Count != 0)
                {
                    List <IOutboundAttachment> source = attachments;

                    Func <IOutboundAttachment, bool> predicate = new Func <IOutboundAttachment, bool>(a => { return(a.UploadState != OutboundAttachmentUploadState.Completed); });//Func<IOutboundAttachment, bool> func = (Func<IOutboundAttachment, bool>) (a => a.UploadState != OutboundAttachmentUploadState.Completed);

                    if (!source.Any <IOutboundAttachment>(predicate))
                    {
                        goto label_4;
                    }
                }
                return(false);
            }
label_4:
            return(true);
        }
Ejemplo n.º 8
0
 internal void AddComment(string commentText, List <IOutboundAttachment> attachments, Action <bool> resultCallback, StickerItemData stickerItemData = null, bool fromGroup = false, string stickerReferrer = "")
 {
     if (!this.CanPostComment(commentText, attachments, stickerItemData))
     {
         resultCallback(false);
     }
     else if (this._isAddingComment)
     {
         resultCallback(false);
     }
     else
     {
         this._isAddingComment = true;
         GroupsService.Current.AddTopicComment(this._gid, this._tid, commentText, attachments.Select <IOutboundAttachment, string>((Func <IOutboundAttachment, string>)(a => a.AttachmentId)).ToList <string>(), (Action <BackendResult <Comment, ResultCode> >)(res =>
         {
             if (res.ResultCode == ResultCode.Succeeded)
             {
                 Execute.ExecuteOnUIThread((Action)(() =>
                 {
                     CommentItem commentItem = this.CreateCommentItem(AppGlobalStateManager.Current.GlobalState.LoggedInUser, res.ResultData, null);
                     MyVirtualizingPanel2 virtPanel = this._virtPanel;
                     int count = this._virtPanel.VirtualizableItems.Count;
                     List <IVirtualizable> itemsToInsert = new List <IVirtualizable>();
                     itemsToInsert.Add((IVirtualizable)commentItem);
                     int num = 0;
                     // ISSUE: variable of the null type
                     virtPanel.InsertRemoveItems(count, itemsToInsert, num != 0, null);
                     this._virtPanel.ScrollToBottom(true);
                     this.PublishChangedEvent();
                     this._isAddingComment = false;
                     resultCallback(true);
                 }));
             }
             else
             {
                 Execute.ExecuteOnUIThread((Action)(() =>
                 {
                     this._isAddingComment = false;
                     resultCallback(false);
                 }));
             }
         }), stickerItemData == null ? 0 : stickerItemData.StickerId, fromGroup, stickerReferrer);
     }
 }