I currently have a class that has an enumeration of graphics extensions that
it supports ie:
Public Enum GraphicFormats
JPG
JPEG
BMP
TIFF
End Enum
When a user selects a file it checks against this enum to verify it has an
okay extension and if I ever want add more files I can just modify this
enum. At some point though I need to translate a variable of the type
GraphicsFormat to type Imaging.ImageFo rmat in order to pass to a function.
I.E. BMP to Imaging.ImageFo rmat.BMP and JPG or JPEG to
Imaging.ImageFo rmat.JPEG.
I thought Maybe I could do the following when the user loads the vaiable:
Public Property FileFormat() As GraphicFormats
Get
If _FileFormat Is Imaging.ImageFo rmat.Jpeg Then
Return GraphicFormats. JPEG
ElseIf _FileFormat Is Imaging.ImageFo rmat.Bmp Then
Return GraphicFormats. BMP
ElseIf _FileFormat Is Imaging.ImageFo rmat.Tiff Then
Return GraphicFormats. TIFF
End If
End Get
Set(ByVal Value As GraphicFormats)
If Value = GraphicFormats. JPEG Or Value = GraphicFormats. JPG
Then
_FileFormat = Imaging.ImageFo rmat.Jpeg
ElseIf Value = GraphicFormats. BMP Then
_FileFormat = Imaging.ImageFo rmat.Bmp
ElseIf Value = GraphicFormats. TIFF Then
_FileFormat = Imaging.ImageFo rmat.Tiff
End If
End Set
End Property
This way the object would really store in _FileFormat of type
Imaging.ImageFo rmat, but when the user access the variable the get a type of
my enumeration. But this doesn't work because if I access _FileFormat in my
class it doesn't have the value, but just an object of type
Imaging.ImageFo rmat, and if I access Me.FileFormat in my class I get a type
of my enum instead.
Also this method kills my ease of adding new extensions to my class. Maybe
I am going about this completely the wrong way. Any suggestions?