예제 #1
0
        private FeedItem CreatePhotoPhotoTagItem(NewsItem newsFeedItem, List <Group> groups, List <User> profiles)
        {
            FeedItem feedItem     = new FeedItem();
            WallPost fromNewsItem = WallPost.CreateFromNewsItem(newsFeedItem);

            feedItem.DefaultTarget       = "/default";
            feedItem.Author.DisplayName  = fromNewsItem.GetAuthorDisplayName(groups, profiles);
            feedItem.Author.RemoteId     = RemoteIdHelper.GenerateUniqueRemoteId(fromNewsItem.from_id.ToString(), RemoteIdHelper.RemoteIdItemType.UserOrGroup);
            feedItem.Author.Username     = feedItem.Author.DisplayName;
            feedItem.ReactionDisplayKind = (ReactionDisplayKind)0;
            feedItem.Timestamp           = new DateTimeOffset(ExtensionsBase.UnixTimeStampToDateTime((double)fromNewsItem.date, true));
            feedItem.Style    = (FeedItemStyle)1;
            feedItem.RemoteId = RemoteIdHelper.GenerateUniqueRemoteId(fromNewsItem.GloballyUniqueId, RemoteIdHelper.RemoteIdItemType.WallPost);
            string photoTagFeedText = this.GetPhotoPhotoTagFeedText(newsFeedItem, groups, profiles);

            if (string.IsNullOrEmpty(photoTagFeedText))
            {
                return(null);
            }
            feedItem.PrimaryContent.Title = photoTagFeedText;
            string photosMode = "Photos";

            if (newsFeedItem.Photo_tags != null && newsFeedItem.Photo_tags.Count > 0)
            {
                photosMode = "PhotoTags";
            }
            this.ProcessAttachmentsIntoFeedItem(fromNewsItem, feedItem, null, null, photosMode);
            if (((ICollection <FeedMediaThumbnail>)feedItem.Thumbnails).Count > 0)
            {
                feedItem.DefaultTarget = feedItem.Thumbnails[0].Target;
            }
            return(feedItem);
        }
예제 #2
0
        private async Task <bool> ProcessSingleDashboardRequest(FeedOperationDetails fod)
        {
            BackendResult <WallData, ResultCode> wall = await WallService.Current.GetWall(RemoteIdHelper.GetItemIdByRemoteId(fod.OwnerRemoteId), 0, 1, "owner");

            if (wall.ResultCode == ResultCode.Succeeded && wall.ResultData.wall.Count > 0)
            {
                WallPost wallPost = wall.ResultData.wall[0];
                FeedItem feedItem = this.CreateFeedItem(wallPost, wall.ResultData.groups, wall.ResultData.profiles, false);
                if (feedItem != null)
                {
                    DashboardItem dashboardItem = await SocialManager.OpenContactDashboardAsync(fod);

                    dashboardItem.DefaultTarget = feedItem.DefaultTarget;
                    dashboardItem.Timestamp     = new DateTimeOffset(ExtensionsBase.UnixTimeStampToDateTime((double)wallPost.date, true));
                    if (!string.IsNullOrEmpty(feedItem.PrimaryContent.Title) || !string.IsNullOrEmpty(feedItem.PrimaryContent.Message))
                    {
                        dashboardItem.Content.Title   = feedItem.PrimaryContent.Title;
                        dashboardItem.Content.Message = feedItem.PrimaryContent.Message;
                    }
                    else
                    {
                        dashboardItem.Content.Title   = feedItem.SecondaryContent.Title;
                        dashboardItem.Content.Message = feedItem.SecondaryContent.Message;
                    }
                    dashboardItem.Content.Target = feedItem.PrimaryContent.Target;
                    await dashboardItem.SaveAsync();

                    return(true);
                }
                wallPost = null;
                feedItem = null;
            }
            return(false);
        }
예제 #3
0
 public static string ForUI(this string backendTextString)
 {
     return(ExtensionsBase.ForUI(backendTextString));
 }
예제 #4
0
        private FeedItem CreateFeedItem(WallPost wallPost, List <Group> groups, List <User> profiles, bool allowFocusComments = true)
        {
            FeedItem feedItem = new FeedItem();
            string   format   = "/default?Action=WallPost&PostId={0}&OwnerId={1}&FocusComments={2}&PollId={3}&PollOwnerId={4}&HideLayout=True";
            long     num1     = 0;
            long     num2     = 0;

            if (wallPost.attachments != null)
            {
                Attachment attachment = wallPost.attachments.FirstOrDefault <Attachment>((Func <Attachment, bool>)(a => a.poll != null));
                if (attachment != null)
                {
                    num1 = attachment.poll.poll_id;
                    num2 = wallPost.IsRepost() ? wallPost.copy_history[0].owner_id : wallPost.to_id;
                }
            }
            feedItem.DefaultTarget = string.Format(format, (object)wallPost.id, (object)wallPost.to_id, allowFocusComments, (object)num1, (object)num2);
            string str1 = string.Format(format, (object)wallPost.id, (object)wallPost.to_id, false, num1, (object)num2);

            feedItem.PrimaryContent.Target   = str1;
            feedItem.SecondaryContent.Target = str1;
            feedItem.Author.DisplayName      = wallPost.GetAuthorDisplayName(groups, profiles);
            Actor  author1         = feedItem.Author;
            long   num3            = wallPost.from_id;
            string uniqueRemoteId1 = RemoteIdHelper.GenerateUniqueRemoteId(num3.ToString(), RemoteIdHelper.RemoteIdItemType.UserOrGroup);

            author1.RemoteId              = uniqueRemoteId1;
            feedItem.ReactionDisplayKind  = (ReactionDisplayKind)2;
            feedItem.ReactionDisplayCount = wallPost.comments == null ? 0 : wallPost.comments.count;
            feedItem.Timestamp            = new DateTimeOffset(ExtensionsBase.UnixTimeStampToDateTime((double)wallPost.date, true));
            feedItem.Style    = FeedItemStyle.Photo;
            feedItem.RemoteId = RemoteIdHelper.GenerateUniqueRemoteId(wallPost.GloballyUniqueId, RemoteIdHelper.RemoteIdItemType.WallPost);
            string secContentTitle   = SocialDataManager.FormatSecondaryContentTitle(wallPost.attachments, wallPost.geo);
            string secContentMessage = SocialDataManager.FormatSecondaryContentMessage(wallPost.attachments, wallPost.geo);

            if (wallPost.IsRepost())
            {
                string str2 = string.Format(format, (object)wallPost.copy_history[0].WallPostOrReplyPostId, (object)wallPost.copy_history[0].owner_id, (object)false, (object)num1, (object)num2);
                if (!string.IsNullOrEmpty(wallPost.text))
                {
                    feedItem.PrimaryContent.Message = TextPreprocessor.PreprocessText(wallPost.text);
                }
                else
                {
                    feedItem.PrimaryContent.Title = wallPost.GetIsMale(profiles) ? BaseResources.SharedPostMale : BaseResources.SharedPostFemale;
                }
                feedItem.ChildItem = new FeedChildItem();
                feedItem.ChildItem.PrimaryContent.Target   = str2;
                feedItem.ChildItem.SecondaryContent.Target = str2;
                bool isMale = false;
                if (wallPost.IsProfilePhotoUpdatePost(profiles, out isMale))
                {
                    feedItem.ChildItem.PrimaryContent.Title = isMale ? BaseResources.Photo_UpdatedProfileMale : BaseResources.Photo_UpdatedProfileFemale;
                }
                feedItem.ChildItem.Timestamp          = feedItem.Timestamp;
                feedItem.ChildItem.Author.DisplayName = wallPost.GetChildAuthorDisplayName(groups, profiles);
                Actor author2 = feedItem.ChildItem.Author;
                num3 = wallPost.GetChildItemFromId();
                string uniqueRemoteId2 = RemoteIdHelper.GenerateUniqueRemoteId(num3.ToString(), RemoteIdHelper.RemoteIdItemType.UserOrGroup);
                author2.RemoteId = uniqueRemoteId2;
                feedItem.ChildItem.DefaultTarget = str2;
                if (!string.IsNullOrWhiteSpace(wallPost.copy_history[0].text))
                {
                    feedItem.ChildItem.PrimaryContent.Message = TextPreprocessor.PreprocessText(wallPost.copy_history[0].text);
                }
                if (wallPost.copy_history[0].attachments != null)
                {
                    List <Attachment> attachments = wallPost.copy_history[0].attachments;
                    List <Photo>      list        = attachments.Where <Attachment>((Func <Attachment, bool>)(a => a.photo != null)).Select <Attachment, Photo>((Func <Attachment, Photo>)(a => a.photo)).ToList <Photo>();
                    string            str3        = CacheManager.TrySerializeToString((IBinarySerializable) new PhotosList()
                    {
                        Photos = list
                    }).ForURL();
                    foreach (Attachment attachment in attachments)
                    {
                        if (attachment.photo != null)
                        {
                            FeedMediaThumbnail feedMediaThumbnail = new FeedMediaThumbnail();
                            feedMediaThumbnail.ImageUrl = attachment.photo.src_big;
                            string str4 = string.Format("/default?Action=ShowPhotos&ViewerMode={0}&PhotosCount={1}&SelectedPhotoIndex={2}&Photos={3}&HideLayout=True", "PhotosByIds", list.Count, ((ICollection <FeedMediaThumbnail>)feedItem.ChildItem.Thumbnails).Count, str3);
                            feedMediaThumbnail.Target = str4;
                            if (((ICollection <FeedMediaThumbnail>)feedItem.ChildItem.Thumbnails).Count < 3)
                            {
                                ((ICollection <FeedMediaThumbnail>)feedItem.ChildItem.Thumbnails).Add(feedMediaThumbnail);
                            }
                        }
                        if (attachment.link != null)
                        {
                            FeedItemSharedStory sharedStoryFromLink = SocialDataManager.TryCreateSharedStoryFromLink(feedItem.Timestamp, attachment.link);
                            if (sharedStoryFromLink != null)
                            {
                                feedItem.ChildItem.SharedStory = sharedStoryFromLink;
                            }
                        }
                        if (attachment.Page != null)
                        {
                            FeedItemSharedStory sharedStoryFromPage = this.TryCreateSharedStoryFromPage(feedItem.Timestamp, attachment.Page);
                            if (sharedStoryFromPage != null)
                            {
                                feedItem.ChildItem.SharedStory = sharedStoryFromPage;
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(secContentTitle) && !string.IsNullOrEmpty(secContentMessage))
                {
                    feedItem.ChildItem.SecondaryContent.Title   = secContentTitle;
                    feedItem.ChildItem.SecondaryContent.Message = secContentMessage;
                }
                if (string.IsNullOrEmpty(feedItem.ChildItem.PrimaryContent.Message) && string.IsNullOrEmpty(feedItem.ChildItem.SecondaryContent.Title) && string.IsNullOrEmpty(feedItem.ChildItem.SecondaryContent.Message))
                {
                    string titleIfNecessary = this.GenerateTitleIfNecessary(wallPost.copy_history[0]);
                    if (!string.IsNullOrEmpty(titleIfNecessary))
                    {
                        feedItem.ChildItem.PrimaryContent.Title = titleIfNecessary;
                    }
                    else
                    {
                        Debugger.Break();
                        feedItem = null;
                    }
                }
            }
            else
            {
                bool isMale = false;
                if (wallPost.text != string.Empty)
                {
                    feedItem.PrimaryContent.Message = TextPreprocessor.PreprocessText(wallPost.text);
                }
                this.ProcessAttachmentsIntoFeedItem(wallPost, feedItem, secContentTitle, secContentMessage, "PhotosByIds");
                if (wallPost.IsProfilePhotoUpdatePost(profiles, out isMale))
                {
                    feedItem.PrimaryContent.Title = isMale ? BaseResources.Photo_UpdatedProfileMale : BaseResources.Photo_UpdatedProfileFemale;
                }
                if (string.IsNullOrEmpty(feedItem.PrimaryContent.Title) && string.IsNullOrEmpty(feedItem.PrimaryContent.Message) && (string.IsNullOrEmpty(feedItem.SecondaryContent.Title) && string.IsNullOrEmpty(feedItem.SecondaryContent.Message)))
                {
                    string titleIfNecessary = this.GenerateTitleIfNecessary(wallPost);
                    if (!string.IsNullOrEmpty(titleIfNecessary))
                    {
                        feedItem.PrimaryContent.Title = titleIfNecessary;
                    }
                    else
                    {
                        Debugger.Break();
                        feedItem = null;
                    }
                }
                if (wallPost.from_id != wallPost.to_id && feedItem != null)
                {
                    feedItem.PrimaryContent.Title = wallPost.GetFromToString(groups, profiles);
                }
            }
            return(feedItem);
        }
예제 #5
0
        public override void Initialize(Link link, double width, string parentPostId = "")
        {
            Photo photo = link.photo;

            if (photo != null)
            {
                double width1 = (double)photo.width;
                double height = (double)photo.height;
                if (height > 0.0 && width1 > 0.0)
                {
                    double requiredHeight = ((FrameworkElement)this.imageContainer).Width / (width1 / height);
                    this._imageUri = ExtensionsBase.ConvertToUri(photo.GetAppropriateForScaleFactor(requiredHeight, 1));
                }
            }
            double    actualHeight1 = this._actualHeight;
            double    height1       = ((FrameworkElement)this.imageContainer).Height;
            Thickness margin1       = ((FrameworkElement)this.imageContainer).Margin;
            // ISSUE: explicit reference operation
            double    top1    = margin1.Top;
            double    num1    = height1 + top1;
            Thickness margin2 = ((FrameworkElement)this.imageContainer).Margin;
            // ISSUE: explicit reference operation
            double bottom1 = ((Thickness)@margin2).Bottom;
            double num2    = num1 + bottom1;

            this._actualHeight = actualHeight1 + num2;
            this._link         = link;
            if (!string.IsNullOrEmpty(link.url) && MetroInMotion.GetTilt((DependencyObject)this.LayoutRoot) != 1.2)
            {
                MetroInMotion.SetTilt((DependencyObject)this.LayoutRoot, 1.2);
            }
            this.ComposeContentTextInlines(link);
            double     num3   = width;
            LinkButton button = link.button;
            string     str1   = button != null ? button.title :  null;
            Thickness  margin3;

            if (!string.IsNullOrEmpty(str1))
            {
                ((UIElement)this.actionButton).Visibility   = Visibility.Visible;
                ((ContentControl)this.actionButton).Content = str1;
                ((UIElement)this.actionButton).Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                TextBlock  textBlock1 = new TextBlock();
                FontFamily fontFamily = new FontFamily("Segoe WP Semibold");
                textBlock1.FontFamily = fontFamily;
                double num4 = 20.0;
                textBlock1.FontSize = num4;
                string str2 = str1;
                textBlock1.Text = str2;
                TextBlock textBlock2  = textBlock1;
                double    num5        = num3;
                double    actualWidth = ((FrameworkElement)textBlock2).ActualWidth;
                margin3 = ((FrameworkElement)this.actionButton).Margin;
                // ISSUE: explicit reference operation
                double left = ((Thickness)@margin3).Left;
                double num6 = actualWidth + left;
                margin3 = ((FrameworkElement)this.actionButton).Margin;
                // ISSUE: explicit reference operation
                double right = ((Thickness)@margin3).Right;
                double num7  = num6 + right + 53.0;
                num3 = num5 - num7;
            }
            ((FrameworkElement)this.textBlockContent).Width = num3;
            LinkProduct product = link.product;
            string      str3;

            if (product == null)
            {
                str3 = null;
            }
            else
            {
                Price price = product.price;
                str3 = price != null ? price.text :  null;
            }
            string     str4   = str3;
            LinkRating rating = link.rating;
            bool       flag1  = !string.IsNullOrEmpty(str4);
            bool       flag2  = rating != null;

            if (flag1 | flag2)
            {
                ((UIElement)this.ratingContainer).Visibility = Visibility.Visible;
                if (flag1)
                {
                    ((UIElement)this.priceBlock).Visibility = Visibility.Visible;
                    this.priceBlock.Text = str4;
                }
                if (flag2)
                {
                    ((UIElement)this.ratingUC).Visibility = Visibility.Visible;
                    this.ratingUC.Value = rating.stars;
                    long reviewsCount = rating.reviews_count;
                    if (reviewsCount > 0L)
                    {
                        ((UIElement)this.votesCountBlock).Visibility = Visibility.Visible;
                        this.votesCountBlock.Text = (string.Format("({0})", UIStringFormatterHelper.FormatForUIVeryShort(reviewsCount)));
                    }
                }
                ((FrameworkElement)this.actionButton).VerticalAlignment = ((VerticalAlignment)2);
                this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.ratingContainer);
            }
            string caption = link.caption;

            if (!string.IsNullOrEmpty(caption))
            {
                ((UIElement)this.captionBlock).Visibility = Visibility.Visible;
                this.captionBlock.Text = caption;
                this._actualHeight     = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.captionBlock);
            }
            this._actualHeight = this._actualHeight + Math.Min(((FrameworkElement)this.textBlockContent).ActualHeight, ((FrameworkElement)this.textBlockContent).MaxHeight);
            double actualHeight2 = this._actualHeight;

            margin3 = ((FrameworkElement)this.textContainer).Margin;
            // ISSUE: explicit reference operation
            double top2 = ((Thickness)@margin3).Top;

            margin3 = ((FrameworkElement)this.textContainer).Margin;
            // ISSUE: explicit reference operation
            double bottom2 = ((Thickness)@margin3).Bottom;
            double num8    = top2 + bottom2;

            this._actualHeight = actualHeight2 + num8;
        }
예제 #6
0
        public override void Initialize(Link link, double width, string parentPostId = "")
        {
            this._link         = link;
            this._parentPostId = parentPostId;
            double val1 = (double)link.photo.width / (double)link.photo.height;
            double num1 = Math.Max(val1, 1.5);
            double num2 = width;
            double num3 = Math.Round(num2 / num1);

            this._imageUri = ExtensionsBase.ConvertToUri(link.photo.GetAppropriateForScaleFactor(num2 / val1, 1));
            ((FrameworkElement)this.canvasImageContainer).Height = num3;
            ((FrameworkElement)this.canvasImageContainer).Width  = num2;
            ((FrameworkElement)this.imagePreview).Height         = num3;
            ((FrameworkElement)this.imagePreview).Width          = num2;
            this._actualHeight = this._actualHeight + num3;
            this.ComposeContentTextInlines(link);
            double    num4    = width;
            Thickness margin1 = ((FrameworkElement)this.gridContent).Margin;
            // ISSUE: explicit reference operation
            double    left1   = margin1.Left;
            double    num5    = num4 - left1;
            Thickness margin2 = ((FrameworkElement)this.gridContent).Margin;
            // ISSUE: explicit reference operation
            double     right  = ((Thickness)@margin2).Right;
            double     num6   = num5 - right;
            LinkButton button = link.button;

            if (button != null)
            {
                ((UIElement)this.buttonAction).Visibility   = Visibility.Visible;
                ((ContentControl)this.buttonAction).Content = button.title;
                ((UIElement)this.buttonAction).Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                TextBlock  textBlock  = new TextBlock();
                FontFamily fontFamily = new FontFamily("Segoe WP Semibold");
                textBlock.FontFamily = fontFamily;
                double num7 = 20.0;
                textBlock.FontSize = num7;
                string title = button.title;
                textBlock.Text = title;
                double    actualWidth = (double)(int)((FrameworkElement)textBlock).ActualWidth;
                Thickness margin3     = ((FrameworkElement)this.buttonAction).Margin;
                // ISSUE: explicit reference operation
                double    left2   = ((Thickness)@margin3).Left;
                double    num8    = actualWidth + left2;
                Thickness margin4 = ((FrameworkElement)this.buttonAction).Margin;
                // ISSUE: explicit reference operation
                double num9  = -((Thickness)@margin4).Right;
                double num10 = num8 + num9 + 32.0;
                num6 -= num10;
            }
            ((FrameworkElement)this.textBlockContent).Width = num6;
            LinkProduct product = link.product;
            string      str;

            if (product == null)
            {
                str = null;
            }
            else
            {
                Price price = product.price;
                str = price != null ? price.text :  null;
            }
            bool flag1 = !string.IsNullOrEmpty(str);
            bool flag2 = link.rating != null;

            if (flag1 | flag2)
            {
                ((UIElement)this.panelProductRating).Visibility = Visibility.Visible;
                if (flag1)
                {
                    ((UIElement)this.textBlockPrice).Visibility = Visibility.Visible;
                    this.textBlockPrice.Text = link.product.price.text;
                }
                if (flag2)
                {
                    ((UIElement)this.ucRating).Visibility = Visibility.Visible;
                    this.ucRating.Value = link.rating.stars;
                    long reviewsCount = link.rating.reviews_count;
                    if (reviewsCount > 0L)
                    {
                        ((UIElement)this.textBlockVotesCount).Visibility = Visibility.Visible;
                        this.textBlockVotesCount.Text = (string.Format("({0})", UIStringFormatterHelper.FormatForUIVeryShort(reviewsCount)));
                    }
                }
                ((FrameworkElement)this.buttonAction).VerticalAlignment = ((VerticalAlignment)2);
                this._actualHeight = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.panelProductRating);
            }
            if (!string.IsNullOrEmpty(link.caption))
            {
                ((UIElement)this.textBlockCaption).Visibility = Visibility.Visible;
                this.textBlockCaption.Text = link.caption;
                this._actualHeight         = this._actualHeight + this.GetElementTotalHeight((FrameworkElement)this.textBlockCaption);
            }
            this._actualHeight = this._actualHeight + Math.Min(((FrameworkElement)this.textBlockContent).ActualHeight, ((FrameworkElement)this.textBlockContent).MaxHeight);
            double    actualHeight = this._actualHeight;
            Thickness margin5      = ((FrameworkElement)this.gridContent).Margin;
            // ISSUE: explicit reference operation
            double    top     = ((Thickness)@margin5).Top;
            Thickness margin6 = ((FrameworkElement)this.gridContent).Margin;
            // ISSUE: explicit reference operation
            double bottom = ((Thickness)@margin6).Bottom;
            double num11  = top + bottom;

            this._actualHeight = actualHeight + num11;
        }