Modify UITypeEditor to get name of image when selected from resources

46 views Asked by At

I am currently working on custom TabControl and I would like to be able to select an image from the tabPage and add it to the TabControl Image List. Since the ImageList requires a key in order to see if an image already exists in the List I was hoping to grab the name of the image when it's selected and use that as the key. An example of what I have in mind is the Image selection for the Button Control.

System.Windows.Forms.Button.Image reference photo

Tab Page Collection properties

I am thinking I may need to make a custom UITypeEditor I have searched other related posts but have not been able to figure out how to emulated an existing UITypeEditor for my purpose, or how to build my own similar editor.

It seems the default Image TypeEditor is able to grab the name of the resource but that information is not available from the Image type. That's why I am hoping I can make my own editor to grab the Image and it's name and pass that through my TabIconItem Type.

I appreciate your help in advance.

[Browsable(true), Category("Appearance")]
[DefaultValue(typeof(Image), null)]
[Editor(typeof(ImageEditor), typeof(System.Drawing.Design.UITypeEditor))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public TabIconItem TabIcon
{
  get
  {
    return tabIcon;
  }
  set
  {
    tabIcon = value;
    Invalidate();
  }
}

public class TabIconItem
{
  private Image _tabIcon;
  private string _tabIconName;
  public Image TabIcon
  {
      get
      {
          return _tabIcon;
      }
      set
      {
          _tabIcon = value;
      }
  }
  public string TabIconName
  {
      get { return _tabIconName; }
      set { _tabIconName = value; }
  }

  public TabIconItem(Image tabIcon, string tabIconName)
  {
      _tabIcon = tabIcon;
      _tabIconName= tabIconName;
  }
}
0

There are 0 answers