Ejemplo n.º 1
0
 public virtual void Update(TLPhotoSizeBase photoSizeBase)
 {
     if (photoSizeBase != null)
     {
         Type = photoSizeBase.Type;
     }
 }
Ejemplo n.º 2
0
        private void InitializeSizes()
        {
            TLPhotoSizeBase thumb = null, medium = null, full = null;
            int             thumbLevel = -1, mediumLevel = -1, fullLevel = -1;

            foreach (var i in Sizes)
            {
                var size = i.Type.Length > 0 ? i.Type[0] : 'z';
                int newThumbLevel = -1, newMediumLevel = -1, newFullLevel = -1;

                switch (size)
                {
                case 's': newThumbLevel = 0; newMediumLevel = 5; newFullLevel = 4; break;     // box 100x100

                case 'm': newThumbLevel = 2; newMediumLevel = 0; newFullLevel = 3; break;     // box 320x320

                case 'x': newThumbLevel = 5; newMediumLevel = 3; newFullLevel = 1; break;     // box 800x800

                case 'y': newThumbLevel = 6; newMediumLevel = 6; newFullLevel = 0; break;     // box 1280x1280

                case 'w': newThumbLevel = 8; newMediumLevel = 8; newFullLevel = 2; break;     // box 2560x2560

                case 'a': newThumbLevel = 1; newMediumLevel = 4; newFullLevel = 8; break;     // crop 160x160

                case 'b': newThumbLevel = 3; newMediumLevel = 1; newFullLevel = 7; break;     // crop 320x320

                case 'c': newThumbLevel = 4; newMediumLevel = 2; newFullLevel = 6; break;     // crop 640x640

                case 'd': newThumbLevel = 7; newMediumLevel = 7; newFullLevel = 5; break;     // crop 1280x1280
                }

                if (newThumbLevel < 0 || newMediumLevel < 0 || newFullLevel < 0)
                {
                    continue;
                }
                if (thumbLevel < 0 || newThumbLevel < thumbLevel)
                {
                    thumbLevel = newThumbLevel;
                    thumb      = i;
                }
                if (mediumLevel < 0 || newMediumLevel < mediumLevel)
                {
                    mediumLevel = newMediumLevel;
                    medium      = i;
                }
                if (fullLevel < 0 || newFullLevel < fullLevel)
                {
                    fullLevel = newFullLevel;
                    full      = i;
                }
            }

            _thumb  = thumb;
            _medium = medium;
            _full   = full;
        }
Ejemplo n.º 3
0
        private void InitializeSizes()
        {
            TLPhotoSizeBase thumb = null, full = null;
            int             thumbLevel = -1, fullLevel = -1;

            foreach (var i in Sizes)
            {
                char size = default(char);
                int  w = 0, h = 0;
                switch (i)
                {
                case TLPhotoSize photoSize:
                {
                    var s = photoSize.Type;
                    if (s.Length > 0)
                    {
                        size = s[0];
                    }
                    w = photoSize.W;
                    h = photoSize.H;
                }
                break;

                case TLPhotoCachedSize cachedSize:
                {
                    var s = cachedSize.Type;
                    if (s.Length > 0)
                    {
                        size = s[0];
                    }
                    w = cachedSize.W;
                    h = cachedSize.H;
                }
                break;
                }
                if (size == default(char) || w == 0 || h == 0)
                {
                    continue;
                }

                int newThumbLevel = Math.Abs((108 * 1) - w), newFullLevel = Math.Abs(2560 - w);
                if (thumbLevel < 0 || newThumbLevel < thumbLevel)
                {
                    thumbLevel = newThumbLevel;
                    thumb      = i;
                }
                if (fullLevel < 0 || newFullLevel < fullLevel)
                {
                    fullLevel = newFullLevel;
                    full      = i;
                }
            }

            _thumb = thumb;
            _full  = full;
        }
Ejemplo n.º 4
0
        public override void Update(TLPhotoSizeBase photoSizeBase)
        {
            base.Update(photoSizeBase);

            var photoSize = photoSizeBase as TLPhotoCachedSize;

            if (photoSize != null)
            {
                W     = photoSize.W;
                H     = photoSize.H;
                Bytes = photoSize.Bytes;
                if (Location != null)
                {
                    Location.Update(photoSize.Location);
                }
                else
                {
                    Location = photoSize.Location;
                }
            }
        }