Ejemplo n.º 1
0
        private Image AddIcon(AnnotateIcon annotateIcon, AnnotateIconSize annotateIconSize)
        {
            var img = IconResource.ExtractAnnotationIcon(annotateIcon, annotateIconSize);

            if (img == null)
            {
                var assembly = Assembly.LoadFrom(@"Atalasoft.dotImage.dll");
                if (assembly != null)
                {
                    var stream = assembly.GetManifestResourceStream("Atalasoft.Imaging.Annotate.Icons._" + annotateIconSize.ToString().Substring(4) + "." + annotateIcon + ".png");
                    img = Image.FromStream(stream);
                }

                if (img == null)
                {
                    if (annotateIconSize.ToString() == "size16")
                    {
                        return(new AtalaImage(16, 16, PixelFormat.Pixel24bppBgr, Color.White).ToBitmap());
                    }
                    if (annotateIconSize.ToString() == "size24")
                    {
                        return(new AtalaImage(24, 24, PixelFormat.Pixel24bppBgr, Color.White).ToBitmap());
                    }
                    if (annotateIconSize.ToString() == "size32")
                    {
                        return(new AtalaImage(32, 32, PixelFormat.Pixel24bppBgr, Color.White).ToBitmap());
                    }
                }
            }

            return(img);
        }
Ejemplo n.º 2
0
        private BitmapSource ExtractAnnotationIcon(AnnotateIcon icon, AnnotateIconSize size)
        {
            BitmapSource returnSource = WpfObjectConverter.ConvertBitmap((Bitmap)IconResource.ExtractAnnotationIcon(icon, size));

            if (returnSource == null)
            {
                Assembly assm = Assembly.LoadFrom(@"Atalasoft.dotImage.dll");
                if (assm != null)
                {
                    Stream stream = assm.GetManifestResourceStream("Atalasoft.Imaging.Annotate.Icons._" + size.ToString().Substring(4) + "." + icon.ToString() + ".png");
                    returnSource = WpfObjectConverter.ConvertBitmap((Bitmap)System.Drawing.Image.FromStream(stream));
                }

                // if it's STILL null, then give up and make placeholders
                if (returnSource == null)
                {
                    switch (size.ToString())
                    {
                    case "size16":
                        returnSource = WpfObjectConverter.ConvertBitmap(new AtalaImage(16, 16, PixelFormat.Pixel24bppBgr, System.Drawing.Color.White).ToBitmap());
                        break;

                    case "size24":
                        returnSource = WpfObjectConverter.ConvertBitmap(new AtalaImage(24, 24, PixelFormat.Pixel24bppBgr, System.Drawing.Color.White).ToBitmap());
                        break;

                    case "size32":
                        returnSource = WpfObjectConverter.ConvertBitmap(new AtalaImage(32, 32, PixelFormat.Pixel24bppBgr, System.Drawing.Color.White).ToBitmap());
                        break;
                    }
                }
            }

            return(returnSource);
        }