protected override void GenerateChildren() { base.GenerateChildren(); List <StickerItemData> stickerItemDataList = this._isHorizontal ? this._horizontalStickers : this._verticalStickers; if (stickerItemDataList.Count == 0) { return; } double num1 = (this.Width - 12.0 * (double)(this.MaxCount + 1)) / (double)this.MaxCount; double num2 = 0.0; if (this._images.Count == 0 || this._recreateImages) { this._images.Clear(); foreach (StickerItemData stickerItemData1 in stickerItemDataList) { double num3 = num2 + 12.0; Image image1 = new Image(); double num4 = num1; ((FrameworkElement)image1).Width = num4; double fixedHeight = this._fixedHeight; ((FrameworkElement)image1).Height = fixedHeight; int num5 = 2; image1.Stretch = ((Stretch)num5); Thickness thickness = new Thickness(num3, 12.0, 0.0, 0.0); ((FrameworkElement)image1).Margin = thickness; StickerItemData stickerItemData2 = stickerItemData1; ((FrameworkElement)image1).Tag = stickerItemData2; Image image2 = image1; Interaction.GetBehaviors((DependencyObject)image2).Add((Behavior) new PreviewBehavior() { PreviewUri = (ScaleFactor.GetRealScaleFactor() == 100 ? stickerItemData1.LocalPathBig : stickerItemData1.LocalPathExtraBig) }); ((UIElement)image2).Tap += (new EventHandler <System.Windows.Input.GestureEventArgs>(this.image_Tap)); num2 = num3 + num1; this._images.Add(image2); } this._recreateImages = false; } int index = 0; using (List <Image> .Enumerator enumerator = this._images.GetEnumerator()) { while (enumerator.MoveNext()) { Image current = enumerator.Current; if (index < stickerItemDataList.Count) { StickerItemData stickerItemData = stickerItemDataList[index]; VeryLowProfileImageLoader.AllowBoostLoading = true; ImageLoader.SetUriSource(current, stickerItemData.LocalPath); } ++index; this.Children.Add((FrameworkElement)current); } } }
protected override void GenerateChildren() { base.GenerateChildren(); List <StickerItemData> stickerItemDataList = this._isHorizontal ? this._horizontalStickers : this._verticalStickers; if (stickerItemDataList.Count == 0) { return; } double num1 = (this.Width - 12.0 * (double)(this.MaxCount + 1)) / (double)this.MaxCount; double num2 = 0.0; if (this._images.Count == 0 || this._recreateImages) { this._images.Clear(); foreach (StickerItemData stickerItemData1 in stickerItemDataList) { double left = num2 + 12.0; Image image1 = new Image(); double num3 = num1; image1.Width = num3; double num4 = this._fixedHeight; image1.Height = num4; int num5 = 2; image1.Stretch = (Stretch)num5; Thickness thickness = new Thickness(left, 12.0, 0.0, 0.0); image1.Margin = thickness; StickerItemData stickerItemData2 = stickerItemData1; image1.Tag = (object)stickerItemData2; Image image2 = image1; Interaction.GetBehaviors((DependencyObject)image2).Add((Behavior) new PreviewBehavior() { PreviewUri = (ScaleFactor.GetRealScaleFactor() == 100 ? stickerItemData1.LocalPathBig : stickerItemData1.LocalPathExtraBig) }); image2.Tap += new EventHandler <GestureEventArgs>(this.image_Tap); num2 = left + num1; this._images.Add(image2); } this._recreateImages = false; } int index = 0; foreach (Image image in this._images) { if (index < stickerItemDataList.Count) { StickerItemData stickerItemData = stickerItemDataList[index]; VeryLowProfileImageLoader.AllowBoostLoading = true; ImageLoader.SetUriSource(image, stickerItemData.LocalPath); } ++index; this.Children.Add((FrameworkElement)image); } }
public Uri GetMapUri(double latitude, double longitude, int zoomLevel, int width, double heightDivisionFactor) { int num1 = width * ScaleFactor.GetRealScaleFactor() / 100; int num2 = 640; int num3 = num1 > num2 ? 2 : 1; int num4 = num3; int num5 = num1 / num4; int num6 = (int)((double)num5 / heightDivisionFactor); return(new Uri(string.Format(MapsService._mapUriFormat, this.CoordinatesToString(latitude, longitude), zoomLevel, num5, num6, num3, CultureInfo.CurrentCulture))); }
public void SetCutArea(double marginLeft, double width) { double num1 = Math.Round(width + 32.0); double num2 = (double)ScaleFactor.GetRealScaleFactor() / 100.0; int divident; int divisor; ScaleFactor.GetScaleFactorLowestFraction(out divident, out divisor, true); double num3 = Math.Round(num1 / (double)divisor) * (double)divident / num2; marginLeft = Math.Round(marginLeft) - 16.0; this.GridCutArea.Width = num3; ((PresentationFrameworkCollection <ColumnDefinition>) this.GridBackground.ColumnDefinitions)[0].Width = (new GridLength(marginLeft)); this.UpdateTrianglePosition(marginLeft + width / 2.0); }
private CoverImage GetImage(double width) { if (this.images == null || this.images.Count == 0) { return(null); } width *= (double)ScaleFactor.GetRealScaleFactor() / 100.0; foreach (CoverImage coverImage in (IEnumerable <CoverImage>) this.images.OrderBy <CoverImage, int>((Func <CoverImage, int>)(i => i.width))) { if ((double)coverImage.width >= width) { return(coverImage); } } return(this.images.LastOrDefault <CoverImage>()); }
private UCItem CreateSnippetItem(Link link, double topMargin) { double num1 = this._isCommentAttachments ? 0.0 : 8.0; double portraitWidth = this._verticalWidth - num1 * 2.0; double num2 = (double)ScaleFactor.GetRealScaleFactor() / 100.0; double num3 = portraitWidth / 2.0 * num2; bool isBigSnippet = (double)link.photo.width >= num3; NewsLinkUCBase tmpUC = !isBigSnippet ? (NewsLinkUCBase) new NewsLinkMediumUC() : (NewsLinkUCBase) new NewsLinkUC(); tmpUC.Initialize(link, portraitWidth); return(new UCItem(portraitWidth, new Thickness(num1, topMargin, num1, 0.0), (Func <UserControlVirtualizable>)(() => { NewsLinkUCBase newsLinkUcBase = !isBigSnippet ? (NewsLinkUCBase) new NewsLinkMediumUC() : (NewsLinkUCBase) new NewsLinkUC(); newsLinkUcBase.Initialize(link, portraitWidth); return (UserControlVirtualizable)newsLinkUcBase; }), (Func <double>)(() => tmpUC.CalculateTotalHeight()), (Action <UserControlVirtualizable>)null, 0.0, false)); }
private UCItem CreateSnippetItem(Link link, double topMargin) { double num1 = this._isCommentAttachments || this._isMessage ? 0.0 : 8.0; double portraitWidth = this._verticalWidth - num1 * 2.0; double landscapeWidth = this._horizontalWidth - num1 * 2.0; double num2 = (double)ScaleFactor.GetRealScaleFactor() / 100.0; double num3 = portraitWidth / 2.0 * num2; Photo photo = link.photo; int? nullable1 = photo != null ? new int?(photo.width) : new int?(); double? nullable2 = nullable1.HasValue ? new double?(nullable1.GetValueOrDefault()) : new double?(); double num4 = num3; bool isBigSnippet = (nullable2.GetValueOrDefault() >= num4 ? (nullable2.HasValue ? 1 : 0) : 0) != 0; NewsLinkUCBase tmpUC = !isBigSnippet ? (!this._isMessage ? (NewsLinkUCBase) new NewsLinkMediumUC() : (NewsLinkUCBase) new MessagesLinkMediumUC(this._isForwardedMessage)) : (!this._isMessage ? (NewsLinkUCBase) new NewsLinkUC() : (NewsLinkUCBase) new MessagesLinkUC()); double width = portraitWidth; if (this._isMessage) { topMargin += 4.0; if (this._isHorizontal) { width = landscapeWidth; } } tmpUC.Initialize(link, width, this._isMessage ? "" : this._parentPostId); return(new UCItem(portraitWidth, new Thickness(num1, topMargin, num1, 0.0), (Func <UserControlVirtualizable>)(() => { NewsLinkUCBase newsLinkUcBase = !isBigSnippet ? (!this._isMessage ? (NewsLinkUCBase) new NewsLinkMediumUC() : (NewsLinkUCBase) new MessagesLinkMediumUC(this._isForwardedMessage)) : (!this._isMessage ? (NewsLinkUCBase) new NewsLinkUC() : (NewsLinkUCBase) new MessagesLinkUC()); width = portraitWidth; if (this._isMessage && this._isHorizontal) { width = landscapeWidth; } newsLinkUcBase.Initialize(link, width, this._isMessage ? "" : this._parentPostId); return (UserControlVirtualizable)newsLinkUcBase; }), (Func <double>)(() => tmpUC.CalculateTotalHeight()), null, this._isMessage ? landscapeWidth : 0.0, this._isMessage && this._isHorizontal)); }
private Canvas GetImage() { double num1; double num2; switch (this._newsfeed.layout) { case UserNotificationNewsfeedLayout.info: num2 = num1 = 44.0; break; case UserNotificationNewsfeedLayout.app: num2 = num1 = 80.0; break; default: UserNotificationImage image1 = this._images[0]; double width1 = (double)image1.width; double height1 = (double)image1.height; if (width1 > 0.0 && height1 > 0.0) { double num3 = width1 / height1; num2 = this._width; num1 = num2 / num3; break; } num2 = num1 = this._width; break; } Image image2 = new Image(); double num4 = num2; ((FrameworkElement)image2).Width = num4; double num5 = num1; ((FrameworkElement)image2).Height = num5; int num6 = 3; image2.Stretch = ((Stretch)num6); int num7 = 1; ((FrameworkElement)image2).HorizontalAlignment = ((HorizontalAlignment)num7); int num8 = 1; ((FrameworkElement)image2).VerticalAlignment = ((VerticalAlignment)num8); this._image = image2; double num9 = (double)ScaleFactor.GetRealScaleFactor() / 100.0; int scaledImageWidth = (int)Math.Round(num2 * num9); int scaledImageHeight = (int)Math.Round(num1 * num9); UserNotificationImage m0 = Enumerable.FirstOrDefault <UserNotificationImage>(this._images, (Func <UserNotificationImage, bool>)(i => { if (i.width >= scaledImageWidth) { return(i.height >= scaledImageHeight); } return(false); })); this._imageUri = ((m0 != null ? ((UserNotificationImage)m0).url : null) ?? ((UserNotificationImage)Enumerable.Last <UserNotificationImage>(this._images)).url).ConvertToUri(); Canvas canvas = new Canvas(); double width2 = ((FrameworkElement)this._image).Width; ((FrameworkElement)canvas).Width = width2; double height2 = ((FrameworkElement)this._image).Height; ((FrameworkElement)canvas).Height = height2; this._imageContainer = canvas; ((PresentationFrameworkCollection <UIElement>)((Panel)this._imageContainer).Children).Add((UIElement)this._image); return(this._imageContainer); }
public SpriteItem(SpriteDescription vertSpriteDesc, SpriteDescription horSpriteDesc, bool isHorizontal) : base(0.0) { this._vertSpriteDescription = vertSpriteDesc; this._horSpriteDescription = horSpriteDesc; this._verticalWidth = (double)vertSpriteDesc.WidthInPixels * 100.0 / (double)ScaleFactor.GetRealScaleFactor(); this._horizontalWidth = (double)horSpriteDesc.WidthInPixels * 100.0 / (double)ScaleFactor.GetRealScaleFactor(); this._verticalHeight = (double)vertSpriteDesc.HeightInPixels * 100.0 / (double)ScaleFactor.GetRealScaleFactor(); this._horizontalHeight = (double)horSpriteDesc.HeightInPixels * 100.0 / (double)ScaleFactor.GetRealScaleFactor(); this._isHorizontal = isHorizontal; this.Width = this._isHorizontal ? this._horizontalWidth : this._verticalWidth; }
public string GetAppropriateForScaleFactor(double requiredHeight, int reduceSizeForLowMemoryDeviceFactor = 1) { int realScaleFactor = ScaleFactor.GetRealScaleFactor(); double num1 = (double)this.width / (double)this.height; if (MemoryInfo.IsLowMemDevice && reduceSizeForLowMemoryDeviceFactor > 0) { requiredHeight /= (double)reduceSizeForLowMemoryDeviceFactor; } requiredHeight *= (double)realScaleFactor / 100.0; double val2 = requiredHeight * num1; double num2 = Math.Max(requiredHeight, val2); string str = ""; if (!string.IsNullOrEmpty(this.photo_75)) { if (num2 <= 75.0) { return(this.photo_75); } str = this.photo_75; } if (!string.IsNullOrEmpty(this.photo_130)) { if (num2 <= 130.0) { return(this.photo_130); } str = this.photo_130; } if (!string.IsNullOrEmpty(this.photo_604)) { if (num2 <= 604.0) { return(this.photo_604); } str = this.photo_604; } if (!string.IsNullOrEmpty(this.photo_807)) { if (num2 <= 807.0) { return(this.photo_807); } str = this.photo_807; } if (!string.IsNullOrEmpty(this.photo_1280)) { if (num2 <= 1280.0) { return(this.photo_1280); } str = this.photo_1280; } if (!string.IsNullOrEmpty(this.photo_2560)) { if (num2 <= 2560.0) { return(this.photo_2560); } str = this.photo_2560; } return(str); }
public string GetAppropriateForScaleFactor(Size size) { int realScaleFactor = ScaleFactor.GetRealScaleFactor(); // ISSUE: explicit reference operation double width = ((Size)@size).Width; // ISSUE: explicit reference operation double height = ((Size)@size).Height; double num1 = width * ((double)realScaleFactor / 100.0); double num2 = height * ((double)realScaleFactor / 100.0); double num3 = (double)this.width / (double)this.height; double val1 = num1 * num3; double val2 = num2 / num3; double num4 = num3 >= 1.0 ? (num3 <= 1.0 ? Math.Min(val1, val2) : (val2 > 0.0 ? val2 : val1)) : (val1 > 0.0 ? val1 : val2); if (num4 == 0.0) { return(""); } string str = ""; if (!string.IsNullOrEmpty(this.photo_75)) { if (num4 <= 75.0) { return(this.photo_75); } str = this.photo_75; } if (!string.IsNullOrEmpty(this.photo_130)) { if (num4 <= 130.0) { return(this.photo_130); } str = this.photo_130; } if (!string.IsNullOrEmpty(this.photo_604)) { if (num4 <= 604.0) { return(this.photo_604); } str = this.photo_604; } if (!string.IsNullOrEmpty(this.photo_807)) { if (num4 <= 807.0) { return(this.photo_807); } str = this.photo_807; } if (!string.IsNullOrEmpty(this.photo_1280)) { if (num4 <= 1280.0) { return(this.photo_1280); } str = this.photo_1280; } if (!string.IsNullOrEmpty(this.photo_2560)) { if (num4 <= 2560.0) { return(this.photo_2560); } str = this.photo_2560; } return(str); }