Example #1
0
        public static async Task <AttachmentIcon> TryCreateAsync(string name, MemoryStream stream)
        {
            AttachmentIcon result = null;

            foreach (var decoderId in DecoderIds)
            {
                stream.Position = 0;

                try
                {
                    var decoder = await BitmapDecoder.CreateAsync(decoderId, stream.AsRandomAccessStream()).AsTask().ConfigureAwait(false);

                    if (!(decoder.PixelWidth <= AttachmentIcon.MaxSize) || !(decoder.PixelHeight <= AttachmentIcon.MaxSize))
                    {
                        continue;
                    }

                    result = new AttachmentIcon(name, stream.ToArray(), (int)decoder.PixelWidth, (int)decoder.PixelHeight);
                    break;
                }
                catch
                {
                    result = null;
                }
            }

            return(result);
        }
 public ChangeIconCommand(PropertiesBag properties, Document document)
     : base(properties, document)
 {
     newIcon = KeyIcon.TryParse(properties) ?? AttachmentIcon.TryParse(properties);
 }
Example #3
0
 public bool Equals(AttachmentIcon other)
 {
     return(other != null && other.pixelWidth == pixelWidth && other.pixelHeight == pixelHeight && pixelData.SequenceEqual(other.pixelData));
 }