Beispiel #1
0
        private void GenerateLayoutForWallPost()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            Thickness margin = new Thickness();
            Action    action = null;

            if (this._preview)
            {
                action = new Action(this.OnMoreOptionsTap);
            }
            if (this._originalHeaderItem == null)
            {
                this._originalHeaderItem = new UserOrGroupHeaderItem(this.Width, new Thickness(), this.IsGroupPost, this._wallPost.date, this._fromUser, this._fromGroup, this.ExtraText, this.IconType, this.PostSourcePlatform, this._isFeedbackItem ? null : action, new Action(this.onNavigatedToUserOrGroup), this.ExtraTextEnd);
                this.VirtualizableChildren.Add((IVirtualizable)this._originalHeaderItem);
            }
            this._originalHeaderItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
            margin.Top += this._originalHeaderItem.FixedHeight + 8.0;
            if (!string.IsNullOrEmpty(this._wallPost.text))
            {
                if (this._originalTextItem == null)
                {
                    this._originalTextItem = new NewsTextItem(this.Width - 32.0, new Thickness(16.0, 0.0, 16.0, 0.0), this._wallPost.text, this._preview, (Action)(() => this.NavigateToWallPostWithComments(false)), 21.3, new FontFamily("Segoe WP"), 28.0, (Brush)null, false, 0.0, HorizontalAlignment.Left, this._wallPost.PostId, TextAlignment.Left, true);
                    this.VirtualizableChildren.Add((IVirtualizable)this._originalTextItem);
                }
                this._originalTextItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                margin.Top += this._originalTextItem.FixedHeight + 8.0;
            }
            this.CanShowLikesSeparator = true;
            if ((!this._wallPost.attachments.IsNullOrEmpty() ? 1 : (this._wallPost.geo != null ? 1 : 0)) != 0)
            {
                if (this._originalAttachmentsItem == null)
                {
                    this._originalAttachmentsItem = new AttachmentsItem(this.Width, new Thickness(), this._wallPost.attachments, this._wallPost.geo, this._wallPost.from_id == 0L || this._wallPost.id <= 0L ? "" : string.Format("{0}_{1}", (object)this._wallPost.from_id, (object)this._wallPost.id), this._wallPost.friends_only == 1, false, false, false, 0.0, false, !this._preview, this._wallPost.PostId);
                    this.VirtualizableChildren.Add((IVirtualizable)this._originalAttachmentsItem);
                }
                this._originalAttachmentsItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                margin.Top += this._originalAttachmentsItem.FixedHeight;
                this.CanShowLikesSeparator = !this._originalAttachmentsItem.IsLastAttachmentMedia;
            }
            if (this._wallPost.signer_id != 0L)
            {
                margin.Top += 8.0;
                if (this._originalSignerItem == null)
                {
                    this._originalSignerItem = new LinkToUserOrGroupItem(this.Width, new Thickness(), new long?(this._wallPost.signer_id), this._users, this._groups, null);
                    this.VirtualizableChildren.Add((IVirtualizable)this._originalSignerItem);
                }
                this._originalSignerItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                margin.Top += this._originalSignerItem.FixedHeight;
                this.CanShowLikesSeparator = true;
            }
            if (!this._wallPost.copy_history.IsNullOrEmpty())
            {
                int index = 0;
                foreach (WallPost wallPost in this._wallPost.copy_history)
                {
                    int currentInd = index;
                    WallPostItem.WallPostHistoryVirtItems historyVirtItems = this._historyVirtItemsDict.ContainsKey(currentInd) ? this._historyVirtItemsDict[currentInd] : new WallPostItem.WallPostHistoryVirtItems();
                    bool   isMale;
                    string pic;
                    string name;
                    this.GetNamePicAndSex(wallPost.from_id, out name, out pic, out isMale);
                    int                num1               = WallPostItem.GetIsProfilePhoto(wallPost.attachments, wallPost.post_source) ? 1 : 0;
                    bool               flag               = wallPost.owner_id < 0L;
                    int                num2               = wallPost.IsRepost() ? 1 : 0;
                    int                num3               = isMale ? 1 : 0;
                    int                num4               = flag ? 1 : 0;
                    string             extraText          = WallPostItem.GetExtraText(num1 != 0, num2 != 0, num3 != 0, num4 != 0);
                    string             extraTextEnd       = WallPostItem.GetExtraTextEnd(wallPost.IsReply);
                    PostSource         postSource         = wallPost.post_source;
                    PostSourcePlatform postSourcePlatform = (PostSourcePlatform)(postSource != null ? (int)postSource.GetPlatform() : 0);
                    string             subtitle           = "";
                    if (!string.IsNullOrEmpty(extraText))
                    {
                        subtitle = extraText.ToLowerInvariant();
                    }
                    else if (wallPost.date != 0)
                    {
                        subtitle = UIStringFormatterHelper.FormatDateTimeForUI(VKClient.Common.Utils.Extensions.UnixTimeStampToDateTime((double)wallPost.date, true));
                    }
                    if (!string.IsNullOrEmpty(extraTextEnd))
                    {
                        subtitle += string.Format(" {0}", (object)extraTextEnd);
                    }
                    margin.Top += 8.0;
                    if (historyVirtItems.HeaderItem == null)
                    {
                        historyVirtItems.HeaderItem = new UCItem(this.Width, new Thickness(), (Func <UserControlVirtualizable>)(() =>
                        {
                            RepostHeaderUC repostHeaderUc = new RepostHeaderUC();
                            this._wallRepostInfo          = new WallRepostInfo()
                            {
                                Pic                = pic,
                                Name               = name,
                                Subtitle           = subtitle,
                                PostSourcePlatform = postSourcePlatform,
                                Width              = this.Width - 16.0
                            };
                            WallRepostInfo configuration = this._wallRepostInfo;
                            repostHeaderUc.Configure(configuration, (Action)(() => this.LinkToUserOrGroupTap(currentInd)));
                            return((UserControlVirtualizable)repostHeaderUc);
                        }), (Func <double>)(() => 56.0), (Action <UserControlVirtualizable>)null, 0.0, false);
                        this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.HeaderItem);
                    }
                    historyVirtItems.HeaderItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                    margin.Top += historyVirtItems.HeaderItem.FixedHeight + 8.0;
                    if (!string.IsNullOrWhiteSpace(wallPost.text))
                    {
                        if (historyVirtItems.TextItem == null)
                        {
                            historyVirtItems.TextItem = new NewsTextItem(this.Width - 32.0, new Thickness(16.0, 0.0, 16.0, 0.0), wallPost.text, this._preview, (Action)(() => this.NavigateToWallPostWithComments(false)), 21.3, new FontFamily("Segoe WP"), 28.0, (Brush)null, false, 0.0, HorizontalAlignment.Left, wallPost.PostId, TextAlignment.Left, true);
                            this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.TextItem);
                        }
                        historyVirtItems.TextItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                        margin.Top += historyVirtItems.TextItem.FixedHeight + 8.0;
                    }
                    if ((!wallPost.attachments.IsNullOrEmpty() ? 1 : (wallPost.geo != null ? 1 : 0)) != 0)
                    {
                        if (historyVirtItems.AttachmentsItem == null)
                        {
                            string itemId = wallPost.from_id == 0L || wallPost.id <= 0L ? "" : string.Format("{0}_{1}", (object)wallPost.from_id, (object)wallPost.id);
                            historyVirtItems.AttachmentsItem = new AttachmentsItem(this.Width, new Thickness(), wallPost.attachments, wallPost.geo, itemId, wallPost.friends_only == 1, false, false, false, 0.0, false, !this._preview, wallPost.PostId);
                            this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.AttachmentsItem);
                        }
                        historyVirtItems.AttachmentsItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                        margin.Top += historyVirtItems.AttachmentsItem.FixedHeight;
                        this.CanShowLikesSeparator = !historyVirtItems.AttachmentsItem.IsLastAttachmentMedia;
                    }
                    if (wallPost.signer_id != 0L)
                    {
                        margin.Top += 8.0;
                        if (historyVirtItems.SignerItem == null)
                        {
                            historyVirtItems.SignerItem = new LinkToUserOrGroupItem(this.Width, new Thickness(), new long?(wallPost.signer_id), this._users, this._groups, null);
                            this.VirtualizableChildren.Add((IVirtualizable)historyVirtItems.SignerItem);
                        }
                        historyVirtItems.SignerItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                        margin.Top += historyVirtItems.SignerItem.FixedHeight;
                        this.CanShowLikesSeparator = true;
                    }
                    this._historyVirtItemsDict[index] = historyVirtItems;
                    ++index;
                }
            }
            if (this._preview)
            {
                bool isReply = this._wallPost.IsReply;
                if (!this.IsSuggestedPostponed && !this._isFeedbackItem && !isReply)
                {
                    if (this.CanShowLikesSeparator)
                    {
                        margin.Top += 8.0;
                    }
                    margin.Top = Math.Round(margin.Top);
                    if (this.LikesAndCommentsItem == null)
                    {
                        this.LikesAndCommentsItem = new LikesAndCommentsItem(this.Width, new Thickness(), this._wallPost, (Action)(() => this.NavigateToWallPostWithComments(true)), this._suppressRepostButton, this.CanShowLikesSeparator);
                        this.VirtualizableChildren.Add((IVirtualizable)this.LikesAndCommentsItem);
                    }
                    this.LikesAndCommentsItem.ViewMargin = new Thickness(0.0, margin.Top, 0.0, 0.0);
                    margin.Top += this.LikesAndCommentsItem.FixedHeight;
                }
                else if (isReply)
                {
                    margin.Top += 8.0;
                }
            }
            else
            {
                margin.Top += 8.0;
            }
            if (this._preview && this.IsSuggested && this._wallPost.can_publish == 1)
            {
                margin.Top += 8.0;
                if (this._publishRejectItem == null)
                {
                    this._publishRejectItem = new UCItem(this.Width, margin, (Func <UserControlVirtualizable>)(() =>
                    {
                        PublicRejectUC publicRejectUc     = new PublicRejectUC();
                        publicRejectUc.buttonPublish.Tap += new EventHandler <System.Windows.Input.GestureEventArgs>(this.buttonPublish_Tap);
                        publicRejectUc.buttonDelete.Tap  += new EventHandler <System.Windows.Input.GestureEventArgs>(this.buttonDelete_Tap);
                        return((UserControlVirtualizable)publicRejectUc);
                    }), (Func <double>)(() => 60.0), (Action <UserControlVirtualizable>)null, 0.0, false);
                    this.VirtualizableChildren.Add((IVirtualizable)this._publishRejectItem);
                }
                margin.Top += this._publishRejectItem.FixedHeight;
            }
            this._height = margin.Top;
            if (this._preview && this._showDivideLine)
            {
                this._height = this._height + this.DividerHeight;
            }
            stopwatch.Stop();
        }
Beispiel #2
0
 protected override void HandleOnNavigatedTo(NavigationEventArgs e)
 {
     base.HandleOnNavigatedTo(e);
     this._fromPhotoPicker = false;
     this._isForwardNav    = e.NavigationMode == 0;
     if (ParametersRepository.Contains("FromPhotoPicker"))
     {
         this._fromPhotoPicker = (bool)ParametersRepository.GetParameterForIdAndReset("FromPhotoPicker");
     }
     if (!this._isInitialized)
     {
         this._adminLevel = int.Parse(((Page)this).NavigationContext.QueryString["AdminLevel"]);
         bool isPublicPage   = ((Page)this).NavigationContext.QueryString["IsPublicPage"] == bool.TrueString;
         bool isNewTopicMode = ((Page)this).NavigationContext.QueryString["IsNewTopicMode"] == bool.TrueString;
         this._isFromWallPostPage = ((Page)this).NavigationContext.QueryString["FromWallPostPage"] == bool.TrueString;
         WallPostViewModel.Mode mode;
         // ISSUE: explicit reference operation
         // ISSUE: cast to a reference type
         Enum.TryParse <WallPostViewModel.Mode>(((Page)this).NavigationContext.QueryString["Mode"], out mode);
         WallPost parameterForIdAndReset1 = ParametersRepository.GetParameterForIdAndReset("PublishWallPost") as WallPost;
         WallPost parameterForIdAndReset2 = ParametersRepository.GetParameterForIdAndReset("EditWallPost") as WallPost;
         Comment  parameterForIdAndReset3 = ParametersRepository.GetParameterForIdAndReset("EditWallComment") as Comment;
         Comment  parameterForIdAndReset4 = ParametersRepository.GetParameterForIdAndReset("EditPhotoComment") as Comment;
         Comment  parameterForIdAndReset5 = ParametersRepository.GetParameterForIdAndReset("EditVideoComment") as Comment;
         Comment  parameterForIdAndReset6 = ParametersRepository.GetParameterForIdAndReset("EditProductComment") as Comment;
         Comment  parameterForIdAndReset7 = ParametersRepository.GetParameterForIdAndReset("EditDiscussionComment") as Comment;
         Dictionary <long, long> parameterForIdAndReset8  = ParametersRepository.GetParameterForIdAndReset("CidToAuthorIdDict") as Dictionary <long, long>;
         WallRepostInfo          parameterForIdAndReset9  = ParametersRepository.GetParameterForIdAndReset("WallRepostInfo") as WallRepostInfo;
         WallPostViewModel       parameterForIdAndReset10 = ParametersRepository.GetParameterForIdAndReset("NewCommentVM") as WallPostViewModel;
         this._shareContentDataProvider = ShareContentDataProviderManager.RetrieveDataProvider();
         if (this._shareContentDataProvider is ShareExternalContentDataProvider)
         {
             ((Page)this).NavigationService.ClearBackStack();
             this.ucHeader.HideSandwitchButton = true;
             this.SuppressMenu = true;
         }
         WallPostViewModel vm;
         if (parameterForIdAndReset1 != null)
         {
             vm = new WallPostViewModel(parameterForIdAndReset1, this._adminLevel, null)
             {
                 WMMode = WallPostViewModel.Mode.PublishWallPost
             }
         }
         ;
         else if (parameterForIdAndReset2 != null)
         {
             vm = new WallPostViewModel(parameterForIdAndReset2, this._adminLevel, parameterForIdAndReset9)
             {
                 WMMode = WallPostViewModel.Mode.EditWallPost
             };
             if (vm.WallRepostInfo != null)
             {
                 RepostHeaderUC repostHeaderUc1 = new RepostHeaderUC();
                 Thickness      thickness       = new Thickness(0.0, 14.0, 0.0, 14.0);
                 ((FrameworkElement)repostHeaderUc1).Margin = thickness;
                 RepostHeaderUC repostHeaderUc2 = repostHeaderUc1;
                 repostHeaderUc2.Configure(vm.WallRepostInfo, null);
                 this.wallRepostContainer.Child = ((UIElement)repostHeaderUc2);
             }
         }
         else
         {
             vm = parameterForIdAndReset3 == null ? (parameterForIdAndReset4 == null ? (parameterForIdAndReset5 == null ? (parameterForIdAndReset6 == null ? (parameterForIdAndReset7 == null ? (parameterForIdAndReset10 == null ? new WallPostViewModel(this.CommonParameters.UserOrGroupId, this.CommonParameters.IsGroup, this._adminLevel, isPublicPage, isNewTopicMode) : parameterForIdAndReset10) : WallPostViewModel.CreateEditDiscussionCommentVM(parameterForIdAndReset7, parameterForIdAndReset8)) : WallPostViewModel.CreateEditProductCommentVM(parameterForIdAndReset6)) : WallPostViewModel.CreateEditVideoCommentVM(parameterForIdAndReset5)) : WallPostViewModel.CreateEditPhotoCommentVM(parameterForIdAndReset4)) : WallPostViewModel.CreateEditWallCommentVM(parameterForIdAndReset3);
         }
         vm.IsOnPostPage = true;
         vm.WMMode       = mode;
         if (!this._fromPhotoPicker && (!e.IsNavigationInitiator || e.NavigationMode != NavigationMode.New || (mode == WallPostViewModel.Mode.NewTopic || mode == WallPostViewModel.Mode.NewWallPost)))
         {
             WallPostVMCacheManager.TryDeserializeVM(vm);
         }
         vm.PropertyChanged += new PropertyChangedEventHandler(this.vm_PropertyChanged);
         base.DataContext    = vm;
         this._isInitialized = true;
     }
     if (this.HandleInputParams(e))
     {
         return;
     }
     this.UpdateViewState();
     ListExtensions.ForEach <IOutboundAttachment>(this.WallPostVM.OutboundAttachments, (Action <IOutboundAttachment>)(a => a.SetRetryFlag()));
     if (!e.IsNavigationInitiator || e.NavigationMode != NavigationMode.New)
     {
         return;
     }
     if (this.WallPostVM.IsInNewWallPostMode || this.WallPostVM.EditWallRepost)
     {
         this.FocusTextBox();
     }
     else
     {
         if (!this.WallPostVM.IsInNewTopicMode)
         {
             return;
         }
         this.FocusTitleTextBox();
     }
 }