コード例 #1
0
        public GraffitiAttachmentItem(string uri, int width, int height)
        {
            this._uri    = uri;
            this._width  = width;
            this._height = height;
            Doc                doc                = new Doc();
            DocPreview         docPreview         = new DocPreview();
            DocPreviewGraffiti docPreviewGraffiti = new DocPreviewGraffiti();

            docPreviewGraffiti.width  = width;
            docPreviewGraffiti.height = height;
            string uri1 = this._uri;

            docPreviewGraffiti.src = uri1;
            docPreview.graffiti    = docPreviewGraffiti;
            doc.preview            = docPreview;
            this.Doc = doc;
        }
コード例 #2
0
        public void CreateOrUpdateLayout()
        {
            List <Attachment>  source = this._attachments;
            DocPreviewGraffiti docPreviewGraffiti1;

            if (source == null)
            {
                docPreviewGraffiti1 = (DocPreviewGraffiti)null;
            }
            else
            {
                Attachment attachment = source.FirstOrDefault <Attachment>((Func <Attachment, bool>)(a => a.doc != null));
                if (attachment == null)
                {
                    docPreviewGraffiti1 = (DocPreviewGraffiti)null;
                }
                else
                {
                    Doc doc = attachment.doc;
                    if (doc == null)
                    {
                        docPreviewGraffiti1 = (DocPreviewGraffiti)null;
                    }
                    else
                    {
                        DocPreview preview = doc.preview;
                        docPreviewGraffiti1 = preview != null ? preview.graffiti : (DocPreviewGraffiti)null;
                    }
                }
            }
            DocPreviewGraffiti docPreviewGraffiti2 = docPreviewGraffiti1;

            if (docPreviewGraffiti2 == null)
            {
                return;
            }
            double num1 = 4.0 / 9.0;
            double val1 = (double)docPreviewGraffiti2.width * num1;
            double num2 = (double)docPreviewGraffiti2.height * num1;
            double num3 = val1 * 1.0 / num2;
            double num4 = Math.Min(val1, 320.0);
            double num5 = num4 / num3;

            this._width  = num4;
            this._height = num5;
            double width  = this._width;
            double height = this._height;

            if (this._isBlackTheme)
            {
                this._width  = this._width + this._extraMargin * 2.0;
                this._height = this._height + this._extraMargin * 2.0;
            }
            string src    = docPreviewGraffiti2.src;
            Stream stream = (Stream)null;
            Uri    uri    = src.ConvertToUri();

            if (!uri.IsAbsoluteUri)
            {
                Stream cachedImageStream = ImageCache.Current.GetCachedImageStream(src);
                if (cachedImageStream != null)
                {
                    stream = (Stream) new MemoryStream();
                    cachedImageStream.CopyTo(stream);
                    cachedImageStream.Close();
                }
            }
            this.VirtualizableChildren.Add(!uri.IsAbsoluteUri ? (IVirtualizable) new VirtualizableImage(width, height, this.GraffitiMargin, stream, (Action <VirtualizableImage>)null, "1", false, false, Stretch.Uniform, (Brush)null, -1.0, false, false) : (IVirtualizable) new VirtualizableImage(width, height, this.GraffitiMargin, src, (Action <VirtualizableImage>)null, "1", false, false, Stretch.Uniform, (Brush)null, -1.0, false, false));
        }
コード例 #3
0
ファイル: GraffitiItem.cs プロジェクト: Makzz90/VKClient_re
        public void CreateOrUpdateLayout()
        {
            List <Attachment>  attachments = this._attachments;
            DocPreviewGraffiti docPreviewGraffiti1;

            if (attachments == null)
            {
                docPreviewGraffiti1 = null;
            }
            else
            {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                // ISSUE: method pointer
                Func <Attachment, bool> func = new Func <Attachment, bool>((a) => { return(a.doc != null); });
                Attachment m0 = Enumerable.FirstOrDefault <Attachment>(attachments, func);
                if (m0 == null)
                {
                    docPreviewGraffiti1 = null;
                }
                else
                {
                    Doc doc = ((Attachment)m0).doc;
                    if (doc == null)
                    {
                        docPreviewGraffiti1 = null;
                    }
                    else
                    {
                        DocPreview preview = doc.preview;
                        docPreviewGraffiti1 = preview != null ? preview.graffiti :  null;
                    }
                }
            }
            DocPreviewGraffiti docPreviewGraffiti2 = docPreviewGraffiti1;

            if (docPreviewGraffiti2 == null)
            {
                return;
            }
            double num1 = 4.0 / 9.0;
            double val1 = (double)docPreviewGraffiti2.width * num1;
            double num2 = (double)docPreviewGraffiti2.height * num1;
            double num3 = val1 * 1.0 / num2;
            double num4 = Math.Min(val1, 320.0);
            double num5 = num4 / num3;

            this._width  = num4;
            this._height = num5;
            double width  = this._width;
            double height = this._height;

            if (this._isBlackTheme)
            {
                this._width  = this._width + this._extraMargin * 2.0;
                this._height = this._height + this._extraMargin * 2.0;
            }
            string src    = docPreviewGraffiti2.src;
            Stream stream = null;
            Uri    uri    = src.ConvertToUri();

            if (!uri.IsAbsoluteUri)
            {
                Stream cachedImageStream = ImageCache.Current.GetCachedImageStream(src);
                if (cachedImageStream != null)
                {
                    stream = (Stream) new MemoryStream();
                    cachedImageStream.CopyTo(stream);
                    cachedImageStream.Close();
                }
            }
            base.VirtualizableChildren.Add(!uri.IsAbsoluteUri ? (IVirtualizable) new VirtualizableImage(width, height, this.GraffitiMargin, stream, null, "1", false, false, (Stretch)2, null, -1.0, false, false) : (IVirtualizable) new VirtualizableImage(width, height, this.GraffitiMargin, src, null, "1", false, false, (Stretch)2, null, -1.0, false, false));
        }