public void LoadDrawingImage_Resize()
        {
            var data = ImageLoader2.ImageToByteArray(Image, drawingImageSize: new System.Windows.Size(150, 45));

            Assert.IsNotNull(data);
            Assert.AreEqual(1821, data.Length);
            Bitmap bitmap = new Bitmap(new MemoryStream(data));

            Assert.AreEqual(ImageFormat.Png, bitmap.RawFormat);
            Assert.AreEqual(System.Drawing.Imaging.PixelFormat.Format32bppArgb, bitmap.PixelFormat);
            Assert.AreEqual(150, bitmap.Width);
            Assert.AreEqual(45, bitmap.Height);
        }
        public void LoadDrawingImage()
        {
            var data = ImageLoader2.ImageToByteArray(Image);

            Assert.IsNotNull(data);
            Assert.AreEqual(3682, data.Length);
            Bitmap bitmap = new Bitmap(new MemoryStream(data));

            Assert.AreEqual(ImageFormat.Png, bitmap.RawFormat);
            Assert.AreEqual(System.Drawing.Imaging.PixelFormat.Format32bppArgb, bitmap.PixelFormat);
            Assert.AreEqual(299, bitmap.Width);
            Assert.AreEqual(86, bitmap.Height);
        }
Exemple #3
0
        public void LoadGenericBitmapSource()
        {
            var data = ImageLoader2.ImageToByteArray(RenderTargetBitmap);

            Assert.IsNotNull(data);
            Assert.AreEqual(304, data.Length);
            Bitmap bitmap = new Bitmap(new MemoryStream(data));

            Assert.AreEqual(ImageFormat.Png, bitmap.RawFormat);
            Assert.AreEqual(System.Drawing.Imaging.PixelFormat.Format32bppArgb, bitmap.PixelFormat);
            Assert.AreEqual(100, bitmap.Width);
            Assert.AreEqual(100, bitmap.Height);
        }
Exemple #4
0
 public bool TryStoreIconToFile(ImageSource icon, string storageFolder, out string iconID, out string iconPath)
 {
     Guard.ArgumentNotNull(icon, "icon");
     byte[] iconBytes = null;
     try {
         iconBytes = ImageLoader2.ImageToByteArray(icon, baseUri);
     } catch (Exception) {
         iconID   = null;
         iconPath = null;
         return(false);
     }
     iconID   = NativeResourceManager.CreateFileName(GetImageHash(iconBytes)) + ".ico";
     iconPath = UnpackIcon(Path.Combine(storageFolder, iconID), iconBytes);
     return(iconPath != null);
 }
        void TestUri(params Uri[] uris)
        {
            List <ImageSource> sources = new List <ImageSource>();

            foreach (Uri uri in uris)
            {
                sources.Add(new BitmapImage(uri));
                sources.Add(ApplicationJumpListServiceTestsImageSourceHelper.GetImageSource(uri));
            }
            foreach (ImageSource source in sources)
            {
                byte[] data = ImageLoader2.ImageToByteArray(source);
                Assert.IsNotNull(data);
                Assert.AreNotEqual(0, data.Length);
                Bitmap bitmap = new Bitmap(new MemoryStream(data));
                Assert.AreEqual(ImageFormat.Png, bitmap.RawFormat);
            }
        }
Exemple #6
0
        public INotification CreatePredefinedNotification(
            string text1,
            string text2,
            string text3,
            ImageSource image = null)
        {
            IPredefinedToastNotificationContentFactory cf      = PredefinedNotificationsFactory.CreateContentFactory();
            IPredefinedToastNotificationContent        content = null;

            switch (PredefinedNotificationTemplate)
            {
            case NotificationTemplate.LongText:
                content = cf.CreateContent(text1);
                break;

            case NotificationTemplate.ShortHeaderAndLongText:
                content = cf.CreateOneLineHeaderContent(text1, text2);
                break;

            case NotificationTemplate.LongHeaderAndShortText:
                content = cf.CreateTwoLineHeaderContent(text1, text2);
                break;

            case NotificationTemplate.ShortHeaderAndTwoTextFields:
                content = cf.CreateOneLineHeaderContent(text1, text2, text3);
                break;
            }
            if (image != null)
            {
                var dpi   = PrimaryScreen.GetDpi();
                var width = PredefinedNotificationsFactory.ImageSize;
                var size  = new Size(width * dpi.X, width * dpi.Y);
                content.SetImage(ImageLoader2.ImageToByteArray(image, GetBaseUri, size));
            }
            content.SetDuration((DevExpress.Internal.NotificationDuration)PredefinedNotificationDuration);
            content.SetSound((DevExpress.Internal.PredefinedSound)Sound);
            return(new MvvmPredefinedNotification {
                Notification = PredefinedNotificationsFactory.CreateToastNotification(content)
            });
        }