예제 #1
0
        private Image GetBitmapFromComponent(Type type)
        {
            Image bmp = ToolboxBitmapAttribute.GetImageFromResource(type, null, false) as Bitmap;

            if (bmp != null)
            {
                return(bmp);
            }
            else
            {
                return(ToolboxBitmapAttribute.Default.GetImage(type));
            }
        }
예제 #2
0
 // only call this for well known items.
 private static Bitmap GetKnownToolboxBitmap(Type itemType)
 {
     if (s_cachedWinformsImages == null)
     {
         s_cachedWinformsImages = new Dictionary <Type, Bitmap>();
     }
     if (!s_cachedWinformsImages.ContainsKey(itemType))
     {
         Bitmap knownImage = ToolboxBitmapAttribute.GetImageFromResource(itemType, null, false) as Bitmap;
         s_cachedWinformsImages[itemType] = knownImage;
         return(knownImage);
     }
     return(s_cachedWinformsImages[itemType]);
 }
 private static Bitmap GetKnownToolboxBitmap(System.Type itemType)
 {
     if (CachedWinformsImages == null)
     {
         CachedWinformsImages = new Dictionary <System.Type, Bitmap>();
     }
     if (!CachedWinformsImages.ContainsKey(itemType))
     {
         Bitmap bitmap = ToolboxBitmapAttribute.GetImageFromResource(itemType, null, false) as Bitmap;
         CachedWinformsImages[itemType] = bitmap;
         return(bitmap);
     }
     return(CachedWinformsImages[itemType]);
 }
예제 #4
0
        public Image GetIcon()
        {
            try
            {
                Type connType = ConnectionType;
                if (connType == null)
                {
                    return(null);
                }

                Image img = ToolboxBitmapAttribute.GetImageFromResource(ConnectionType, null, true);
                return(img);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #5
0
        public bool Execute(object source, object target)
        {
            var    FolderView             = (IFolderView)GetService(typeof(IFolderView));
            string CurrentFolderLocalPath = GetFolderLocalPath(FolderView.CurrentFolder);

            CommandProcessorController Controller = new CmdPromptTabController();

            if (Controller.Start(CurrentFolderLocalPath))
            {
                var TabManager = (ITabManager)GetService(typeof(ITabManager));

                ITab Tab = TabManager.AddNewTab(Controller.OutputBox, "Command Processor");
                Tab.Image = ToolboxBitmapAttribute.GetImageFromResource(typeof(NewCmdPromptTabCommand), "application_xp_terminal.png", false);
                Tab.Select();

                return(true);
            }

            return(false);
        }
예제 #6
0
        // FIXME - Should we be returning empty bitmap, or null?
        public virtual void Initialize(Type type)
        {
            CheckUnlocked();
            if (type == null)
            {
                return;
            }

            AssemblyName = type.Assembly.GetName();
            DisplayName  = type.Name;
            TypeName     = type.FullName;

            // seems to be a right place to create the bitmap
            System.DrawingCore.Image image = null;
            foreach (object attribute in type.GetCustomAttributes(true))
            {
                ToolboxBitmapAttribute tba = attribute as ToolboxBitmapAttribute;
                if (tba != null)
                {
                    image = tba.GetImage(type);
                    break;
                }
            }
            //fallback: check for image even if not attribute
            if (image == null)
            {
                image = ToolboxBitmapAttribute.GetImageFromResource(type, null, false);
            }

            if (image != null)
            {
                Bitmap = (image as Bitmap);
                if (Bitmap == null)
                {
                    Bitmap = new Bitmap(image);
                }
            }

            Filter = type.GetCustomAttributes(typeof(ToolboxItemFilterAttribute), true);
        }