Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
        private Button CreateToolbarButton(string tooltip, AnnotateIcon icon)
        {
            Image img = new Image();

            img.Source = ExtractAnnotationIcon(icon, AnnotateIconSize.Size24);

            Button btn = new Button();

            btn.Content = img;
            btn.ToolTip = tooltip;
            btn.Click  += new RoutedEventHandler(AnnotationToolbar_Click);

            return(btn);
        }