private static VoiceMessageItem GetVoiceMessageItem(IVirtualizable item) { MessageItem messageItem = item as MessageItem; MessageContentItem messageContentItem = messageItem == null ? item as MessageContentItem : messageItem.VirtualizableChildren.FirstOrDefault <IVirtualizable>((Func <IVirtualizable, bool>)(i => i is MessageContentItem)) as MessageContentItem; if (messageContentItem != null) { if (messageContentItem.ForwardedList != null && messageContentItem.ForwardedList.Count > 0) { return((VoiceMessageItem)null); } AttachmentsItem attachmentsItem = messageContentItem.VirtualizableChildren.FirstOrDefault <IVirtualizable>((Func <IVirtualizable, bool>)(i => i is AttachmentsItem)) as AttachmentsItem; VoiceMessageItem voiceMessageItem = (attachmentsItem != null ? attachmentsItem.VirtualizableChildren.FirstOrDefault <IVirtualizable>((Func <IVirtualizable, bool>)(i => i is VoiceMessageItem)) : (IVirtualizable)null) as VoiceMessageItem; if (voiceMessageItem != null) { return(voiceMessageItem); } } return((VoiceMessageItem)null); }
private void CreateLayout() { try { if (!this.IsSystemMessage) { if (!this._isTypingItem) { bool flag = !string.IsNullOrWhiteSpace(this._mvm.Message.body); int num1 = this._mvm.Attachments == null ? 0 : (Enumerable.Any <AttachmentViewModel>(this._mvm.Attachments, (Func <AttachmentViewModel, bool>)(a => a.AttachmentType == AttachmentType.Gift)) ? 1 : 0); double verticalWidth = 356.0; double horizontalWidth = 512.0; if (num1 != 0 && !flag) { verticalWidth = horizontalWidth = 256.0; } this._messageContentItem = new MessageContentItem(verticalWidth, new Thickness(), this._mvm, horizontalWidth, this._isHorizontalOrientation, 0); MessageDirectionType messageDirectionType = this._mvm.MessageDirectionType; double width = this._messageContentItem.Width; SolidColorBrush bgBrush1 = this._mvm.BGBrush; Rectangle rectangle = new Rectangle(); SolidColorBrush solidColorBrush = bgBrush1; ((Shape)rectangle).Fill = ((Brush)solidColorBrush); double num2 = width; ((FrameworkElement)rectangle).Width = num2; double fixedHeight = this._messageContentItem.FixedHeight; ((FrameworkElement)rectangle).Height = fixedHeight; this._bubbleRect = rectangle; this._selectionPath = new Path(); PathGeometry pathGeometry = new PathGeometry(); PathFigure pathFigure1 = new PathFigure(); PathFigure pathFigure2 = pathFigure1; Point point1 = new Point(); // ISSUE: explicit reference operation point1.X = 361.0; // ISSUE: explicit reference operation point1.Y = 239.0; Point point2 = point1; pathFigure2.StartPoint = point2; LineSegment lineSegment1 = new LineSegment(); Point p1 = new Point(); // ISSUE: explicit reference operation p1.X = 371.0; // ISSUE: explicit reference operation p1.Y = 250.0; Point point3 = p1; lineSegment1.Point = point3; LineSegment lineSegment2 = lineSegment1; LineSegment lineSegment3 = new LineSegment(); p1 = new Point(); // ISSUE: explicit reference operation p1.X = 387.0; // ISSUE: explicit reference operation p1.Y = 230.0; Point point4 = p1; lineSegment3.Point = point4; LineSegment lineSegment4 = lineSegment3; ((PresentationFrameworkCollection <PathSegment>)pathFigure1.Segments).Add((PathSegment)lineSegment2); ((PresentationFrameworkCollection <PathSegment>)pathFigure1.Segments).Add((PathSegment)lineSegment4); ((PresentationFrameworkCollection <PathFigure>)pathGeometry.Figures).Add(pathFigure1); this._selectionPath.Data = ((Geometry)pathGeometry); ((Shape)this._selectionPath).Stretch = ((Stretch)1); ((FrameworkElement)this._selectionPath).Height = 20.5; ((FrameworkElement)this._selectionPath).Width = 25.667; ((Shape)this._selectionPath).StrokeThickness = 5.0; ((Shape)this._selectionPath).Stroke = (Application.Current.Resources["PhoneVKSubtleBrush"] as Brush); ((UIElement)this._selectionPath).Visibility = this._mvm.SelectionMarkVisibility; switch (messageDirectionType) { case MessageDirectionType.InFromUser: this._messageContentItem.Margin = MessageItem.UserIncomingMessageMargin; ((FrameworkElement)this._selectionPath).Margin = (new Thickness(this._messageContentItem.Width + 10.0, 10.0, 0.0, 0.0)); Path path1 = new Path(); SolidColorBrush bgBrush2 = this._mvm.BGBrush; ((Shape)path1).Fill = ((Brush)bgBrush2); double num3 = 16.0; ((FrameworkElement)path1).Height = num3; double num4 = 13.0; ((FrameworkElement)path1).Width = num4; Thickness thickness1 = new Thickness(-12.0, 16.0, 0.0, 0.0); ((FrameworkElement)path1).Margin = thickness1; int num5 = 1; ((Shape)path1).Stretch = ((Stretch)num5); p1 = new Point(); Geometry triangleGeometry1 = PathHelper.CreateTriangleGeometry(p1, new Point(100.0, 0.0), new Point(100.0, 100.0)); path1.Data = triangleGeometry1; this._calloutPath = path1; break; case MessageDirectionType.InFromUserInChat: this._messageContentItem.Margin = MessageItem.ChatIncomingMessageMargin; Path selectionPath1 = this._selectionPath; Thickness margin1 = this._messageContentItem.Margin; // ISSUE: explicit reference operation Thickness thickness2 = new Thickness(margin1.Left + this._messageContentItem.Width + 10.0, 10.0, 0.0, 0.0); ((FrameworkElement)selectionPath1).Margin = thickness2; if (this._mvm.UIImageUrl != null) { base.VirtualizableChildren.Add((IVirtualizable) new VirtualizableImage(48.0, 48.0, new Thickness(), this._mvm.UIImageUrl, (Action <VirtualizableImage>)(vi => { if (this._mvm.AssociatedUser == null) { return; } Navigator.Current.NavigateToUserProfile(this._mvm.AssociatedUser.uid, "", "", false); }), "", true, true, (Stretch)3, null, -1.0, false, true)); } ((FrameworkElement)this._bubbleRect).Margin = MessageItem.ChatIncomingMessageMargin; Path path2 = new Path(); SolidColorBrush bgBrush3 = this._mvm.BGBrush; ((Shape)path2).Fill = ((Brush)bgBrush3); double num6 = 16.0; ((FrameworkElement)path2).Height = num6; double num7 = 13.0; ((FrameworkElement)path2).Width = num7; Thickness thickness3 = new Thickness(56.0, 16.0, 0.0, 0.0); ((FrameworkElement)path2).Margin = thickness3; int num8 = 1; ((Shape)path2).Stretch = ((Stretch)num8); p1 = new Point(); Geometry triangleGeometry2 = PathHelper.CreateTriangleGeometry(p1, new Point(100.0, 0.0), new Point(100.0, 100.0)); path2.Data = triangleGeometry2; this._calloutPath = path2; break; case MessageDirectionType.OutToUser: case MessageDirectionType.OutToChat: this._messageContentItem.Margin = new Thickness(this.Width - width, 0.0, 0.0, 0.0); Path selectionPath2 = this._selectionPath; Thickness margin2 = this._messageContentItem.Margin; // ISSUE: explicit reference operation Thickness thickness4 = new Thickness(((Thickness)@margin2).Left - 10.0 - ((FrameworkElement)this._selectionPath).Width, 10.0, 0.0, 0.0); ((FrameworkElement)selectionPath2).Margin = thickness4; Path path3 = new Path(); SolidColorBrush bgBrush4 = this._mvm.BGBrush; ((Shape)path3).Fill = ((Brush)bgBrush4); double num9 = 16.0; ((FrameworkElement)path3).Height = num9; double num10 = 13.0; ((FrameworkElement)path3).Width = num10; Thickness thickness5 = new Thickness(this.Width - 1.0, 16.0, 0.0, 0.0); ((FrameworkElement)path3).Margin = thickness5; int num11 = 1; ((Shape)path3).Stretch = ((Stretch)num11); p1 = new Point(); Geometry triangleGeometry3 = PathHelper.CreateTriangleGeometry(p1, new Point(100.0, 0.0), new Point(0.0, 100.0)); path3.Data = triangleGeometry3; this._calloutPath = path3; ((FrameworkElement)this._bubbleRect).Margin = (new Thickness(this.Width - width, 0.0, 0.0, 0.0)); break; case MessageDirectionType.Undefined: return; } base.VirtualizableChildren.Add((IVirtualizable)this._messageContentItem); this._height = this._messageContentItem.FixedHeight; this._tapHandlerItem = new TapHandlerItem(this.Width, this._height, this._mvm); base.VirtualizableChildren.Add((IVirtualizable)this._tapHandlerItem); } else { this._height = 52.0; SolidColorBrush bgBrush1 = this._mvm.BGBrush; this._selectionPath = new Path(); Rectangle rectangle = new Rectangle(); SolidColorBrush solidColorBrush = bgBrush1; ((Shape)rectangle).Fill = ((Brush)solidColorBrush); double num1 = 80.0; ((FrameworkElement)rectangle).Width = num1; double num2 = 52.0; ((FrameworkElement)rectangle).Height = num2; this._bubbleRect = rectangle; VirtualizableImage virtualizableImage1 = new VirtualizableImage(48.0, 12.0, new Thickness(16.0, 22.0, 0.0, 0.0), MultiResolutionHelper.Instance.AppendResolutionSuffix("/Resources/New/TypingBubbleDots.png", true, ""), null, null, false, false, (Stretch)3, null, -1.0, false, false); base.VirtualizableChildren.Add((IVirtualizable)virtualizableImage1); if (this._isTypingInChat) { ((FrameworkElement)this._bubbleRect).Margin = MessageItem.ChatIncomingMessageMargin; VirtualizableImage virtualizableImage2 = virtualizableImage1; Thickness margin1 = virtualizableImage1.Margin; // ISSUE: explicit reference operation double left1 = margin1.Left; margin1 = ((FrameworkElement)this._bubbleRect).Margin; // ISSUE: explicit reference operation double left2 = margin1.Left; double num3 = left1 + left2; Thickness thickness1 = virtualizableImage1.Margin; // ISSUE: explicit reference operation double top1 = ((Thickness)@thickness1).Top; thickness1 = ((FrameworkElement)this._bubbleRect).Margin; // ISSUE: explicit reference operation double top2 = ((Thickness)@thickness1).Top; double num4 = top1 + top2; double num5 = 0.0; double num6 = 0.0; Thickness thickness2 = new Thickness(num3, num4, num5, num6); virtualizableImage2.Margin = thickness2; Path path = new Path(); SolidColorBrush bgBrush2 = this._mvm.BGBrush; ((Shape)path).Fill = ((Brush)bgBrush2); double num7 = 16.0; ((FrameworkElement)path).Height = num7; double num8 = 13.0; ((FrameworkElement)path).Width = num8; Thickness thickness3 = new Thickness(56.0, 16.0, 0.0, 0.0); ((FrameworkElement)path).Margin = thickness3; int num9 = 1; ((Shape)path).Stretch = ((Stretch)num9); Geometry triangleGeometry = PathHelper.CreateTriangleGeometry(new Point(), new Point(100.0, 0.0), new Point(100.0, 100.0)); path.Data = triangleGeometry; this._calloutPath = path; if (this._userTyping == null || this._userTyping.photo_max == null) { return; } double width = 52.0; double height = 52.0; thickness1 = new Thickness(); Thickness margin2 = thickness1; string photoMax = this._userTyping.photo_max; Action <VirtualizableImage> callbackOnTap = (Action <VirtualizableImage>)(vi => { if (this._mvm.AssociatedUser == null) { return; } Navigator.Current.NavigateToUserProfile(this._mvm.AssociatedUser.uid, "", "", false); }); string tag = ""; int num10 = 1; int num11 = 1; int num12 = 3; // ISSUE: variable of the null type double placeholderOpacity = -1.0; int num13 = 0; int num14 = 1; base.VirtualizableChildren.Add((IVirtualizable) new VirtualizableImage(width, height, margin2, photoMax, callbackOnTap, tag, num10 != 0, num11 != 0, (Stretch)num12, null, placeholderOpacity, num13 != 0, num14 != 0)); } else { Path path = new Path(); SolidColorBrush bgBrush2 = this._mvm.BGBrush; ((Shape)path).Fill = ((Brush)bgBrush2); double num3 = 16.0; ((FrameworkElement)path).Height = num3; double num4 = 13.0; ((FrameworkElement)path).Width = num4; Thickness thickness = new Thickness(-12.0, 16.0, 0.0, 0.0); ((FrameworkElement)path).Margin = thickness; int num5 = 1; ((Shape)path).Stretch = ((Stretch)num5); Geometry triangleGeometry = PathHelper.CreateTriangleGeometry(new Point(), new Point(100.0, 0.0), new Point(100.0, 100.0)); path.Data = triangleGeometry; this._calloutPath = path; } } } else { this._systemMessageItem = new SystemMessageItem(MessageItem.VERTICAL_WIDTH, new Thickness(), this._mvm, MessageItem.HORIZONTAL_WIDTH, this._isHorizontalOrientation); this._height = this._systemMessageItem.FixedHeight; base.VirtualizableChildren.Add((IVirtualizable)this._systemMessageItem); } } catch (Exception) { Logger.Instance.Error("Failed to create message layout!!"); } }
private void GenerateLayout() { double num1 = this._marginTop; if (this._mvm.IsForwarded)//Идёт добавление шапки { if (this._forwardedHeaderItem == null) { this._forwardedHeaderItem = new ForwardedHeaderItem(this._verticalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft, new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0), this._mvm); base.VirtualizableChildren.Add(this._forwardedHeaderItem); } num1 = num1 + this._forwardedHeaderItem.FixedHeight + (double)MessageContentItem.MARGIN_BETWEEN; } string body = this._mvm.Message.body; bool flag1 = !string.IsNullOrWhiteSpace(body); bool flag2 = this._mvm.Attachments != null && Enumerable.Any <AttachmentViewModel>(this._mvm.Attachments, (Func <AttachmentViewModel, bool>)(a => a.AttachmentType == AttachmentType.Gift)); bool isStickersGift = false; long stickersProductId = 0; bool isForwarded = this._mvm.IsForwarded; bool flag3 = this._mvm.Message.@out == 0; if (flag2) { AttachmentViewModel m0 = Enumerable.FirstOrDefault <AttachmentViewModel>(this._mvm.Attachments, (Func <AttachmentViewModel, bool>)(a => a.AttachmentType == AttachmentType.Gift)); Gift gift = m0 != null ? m0.Gift : null; if (gift != null) { stickersProductId = gift.stickers_product_id; isStickersGift = (ulong)stickersProductId > 0UL; } } if (flag1 && !flag2) { if (this._textItem == null) { this._textItem = new NewsTextItem(this._verticalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft, new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0), body, false, null, 25.33, new FontFamily("Segoe WP Semilight"), 32.0, (Brush)(Application.Current.Resources["PhoneForegroundBrush"] as SolidColorBrush), this._isHorizontalOrientation, this._horizontalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft, (HorizontalAlignment)0, "", (TextAlignment)1, true, null, false, false); base.VirtualizableChildren.Add((IVirtualizable)this._textItem); } this._textItem.IsHorizontalOrientation = this.IsHorizontalOrientation; this._textItem.Margin = new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0); num1 += this._textItem.FixedHeight; } if (this._mvm.Attachments != null && ((Collection <AttachmentViewModel>) this._mvm.Attachments).Count > 0) { if (this._textItem != null) { num1 += (double)MessageContentItem.MARGIN_BETWEEN; } Geo geo1 = (Geo)Enumerable.FirstOrDefault <Geo>(Enumerable.Select <AttachmentViewModel, Geo>(Enumerable.Where <AttachmentViewModel>(this._mvm.Attachments, (Func <AttachmentViewModel, bool>)(a => a.Geo != null)), (Func <AttachmentViewModel, Geo>)(a => a.Geo))); List <Attachment> list = Enumerable.ToList <Attachment>(Enumerable.Select <AttachmentViewModel, Attachment>(Enumerable.Where <AttachmentViewModel>(this._mvm.Attachments, (Func <AttachmentViewModel, bool>)(a => a.Attachment != null)), (Func <AttachmentViewModel, Attachment>)(a => a.Attachment))); if (this._attachmentsItem == null) { double num2 = this._verticalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft; double num3 = this._horizontalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft; if (num2 > MessageContentItem.MIN_WIDTH) { string str = this._mvm.Message.from_id != 0L ? this._mvm.Message.from_id.ToString() : ""; double width = num2; Thickness margin = new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0); List <Attachment> attachments = list; Geo geo2 = geo1; string itemId = str; int num4 = 0; int num5 = 0; int num6 = 1; int num7 = this._isHorizontalOrientation ? 1 : 0; double horizontalWidth = num3; int num8 = this._mvm.Message.@out == 1 ? 1 : 0; int num9 = 0; string hyperlinkId = ""; // ISSUE: variable of the null type User parentDialogUser = this._mvm != null ? this._mvm.AssociatedUser : null; int num10 = this._mvm != null ? (this._mvm.IsForwarded ? 1 : 0) : 0; this._attachmentsItem = new AttachmentsItem(width, margin, attachments, geo2, itemId, num4 != 0, num5 != 0, num6 != 0, num7 != 0, horizontalWidth, num8 != 0, num9 != 0, hyperlinkId, null, parentDialogUser, num10 != 0); base.VirtualizableChildren.Add((IVirtualizable)this._attachmentsItem); } } if (this._attachmentsItem != null) { this._attachmentsItem.IsHorizontal = this.IsHorizontalOrientation; this._attachmentsItem.Margin = new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0); num1 += this._attachmentsItem.FixedHeight; } } if (flag2) { if (this._giftCaptionItem == null) { this._giftCaptionItem = new GiftCaptionItem(this._verticalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft, this._horizontalWidth - this._marginLeft - this.ForwardedMarginLeft, this.IsHorizontalOrientation, new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0), isStickersGift, isForwarded); base.VirtualizableChildren.Add((IVirtualizable)this._giftCaptionItem); } this._giftCaptionItem.IsLandscape = this.IsHorizontalOrientation; this._giftCaptionItem.Margin = new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0); num1 += this._giftCaptionItem.FixedHeight; if (flag1) { if (this._textItem == null) { SolidColorBrush solidColorBrush = isForwarded ? Application.Current.Resources["PhoneAlmostBlackBrush"] as SolidColorBrush : Application.Current.Resources["PhoneDialogGiftMessageForegroundBrush"] as SolidColorBrush; this._textItem = new NewsTextItem(this._verticalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft, new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0), body, false, null, 21.3, new FontFamily("Segoe WP"), 28.0, (Brush)solidColorBrush, this._isHorizontalOrientation, this._horizontalWidth - this._marginLeft * 2.0 - this.ForwardedMarginLeft, isForwarded ? (HorizontalAlignment)0 : (HorizontalAlignment)1, "", isForwarded ? (TextAlignment)1 : (TextAlignment)0, true, null, false, false); base.VirtualizableChildren.Add((IVirtualizable)this._textItem); } this._textItem.IsHorizontalOrientation = this.IsHorizontalOrientation; this._textItem.Margin = new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0); num1 += this._textItem.FixedHeight; } if (flag3 & isStickersGift && !isForwarded) { if (flag1) { num1 += (double)(MessageContentItem.MARGIN_BETWEEN * 2); } if (this._giftStickersButtonItem == null) { this._giftStickersButtonItem = new GiftStickersButtonItem(this._verticalWidth, this._horizontalWidth, this.IsHorizontalOrientation, new Thickness(0.0, num1, 0.0, 0.0), stickersProductId); base.VirtualizableChildren.Add(this._giftStickersButtonItem); } this._giftStickersButtonItem.IsLandscape = this.IsHorizontalOrientation; this._giftStickersButtonItem.Margin = new Thickness(0.0, num1, 0.0, 0.0); num1 += this._giftStickersButtonItem.FixedHeight; } } if (this._mvm.ForwardedMessages != null && (this._mvm.ForwardedMessages).Count > 0) { if (this._textItem != null || this._attachmentsItem != null) { num1 += (double)MessageContentItem.MARGIN_BETWEEN; } if (this._forwardedList == null) { this._forwardedList = new List <MessageContentItem>(); using (IEnumerator <MessageViewModel> enumerator = (this._mvm.ForwardedMessages).GetEnumerator()) { while (enumerator.MoveNext()) { MessageViewModel current = enumerator.Current; double verticalWidth = this._verticalWidth - this._marginLeft - this.ForwardedMarginLeft; double horizontalWidth = this._horizontalWidth - this._marginLeft - this.ForwardedMarginLeft; if (verticalWidth > MessageContentItem.MIN_WIDTH && this._lvl < MessageContentItem.MAX_LEVEL) { MessageContentItem messageContentItem = new MessageContentItem(verticalWidth, new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0), current, horizontalWidth, this.IsHorizontalOrientation, this._lvl + 1); base.VirtualizableChildren.Add((IVirtualizable)messageContentItem); this._forwardedList.Add(messageContentItem); num1 += messageContentItem.FixedHeight; num1 += (double)MessageContentItem.MARGIN_BETWEEN; } } } } else { foreach (MessageContentItem forwarded in this._forwardedList) { forwarded.IsHorizontalOrientation = this.IsHorizontalOrientation; forwarded.Margin = new Thickness(this._marginLeft + this.ForwardedMarginLeft, num1, 0.0, 0.0); num1 += forwarded.FixedHeight; num1 += (double)MessageContentItem.MARGIN_BETWEEN; } } if (Enumerable.Any <MessageContentItem>(this._forwardedList)) { num1 -= (double)MessageContentItem.MARGIN_BETWEEN; } } if (!this._mvm.IsForwarded) { if (this._messageFooterItem == null) { this._messageFooterItem = new MessageFooterItem(this._verticalWidth - this._marginLeft * 2.0, new Thickness(this._marginLeft, num1, 0.0, 0.0), this._mvm, this.IsHorizontalOrientation, this._horizontalWidth - this._marginLeft * 2.0); base.VirtualizableChildren.Add(this._messageFooterItem); } else { this._messageFooterItem.IsHorizontalOrientation = this.IsHorizontalOrientation; this._messageFooterItem.Margin = new Thickness(this._marginLeft, num1, 0.0, 0.0); } num1 += this._messageFooterItem.FixedHeight + (double)MessageContentItem.MARGIN_BETWEEN; } if (!this._mvm.IsForwarded) { num1 += this._marginTop; } this._height = num1; }