D
David A. Osborn
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.ImageFormat in order to pass to a function.
I.E. BMP to Imaging.ImageFormat.BMP and JPG or JPEG to
Imaging.ImageFormat.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.ImageFormat.Jpeg Then
Return GraphicFormats.JPEG
ElseIf _FileFormat Is Imaging.ImageFormat.Bmp Then
Return GraphicFormats.BMP
ElseIf _FileFormat Is Imaging.ImageFormat.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.ImageFormat.Jpeg
ElseIf Value = GraphicFormats.BMP Then
_FileFormat = Imaging.ImageFormat.Bmp
ElseIf Value = GraphicFormats.TIFF Then
_FileFormat = Imaging.ImageFormat.Tiff
End If
End Set
End Property
This way the object would really store in _FileFormat of type
Imaging.ImageFormat, 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.ImageFormat, 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?
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.ImageFormat in order to pass to a function.
I.E. BMP to Imaging.ImageFormat.BMP and JPG or JPEG to
Imaging.ImageFormat.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.ImageFormat.Jpeg Then
Return GraphicFormats.JPEG
ElseIf _FileFormat Is Imaging.ImageFormat.Bmp Then
Return GraphicFormats.BMP
ElseIf _FileFormat Is Imaging.ImageFormat.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.ImageFormat.Jpeg
ElseIf Value = GraphicFormats.BMP Then
_FileFormat = Imaging.ImageFormat.Bmp
ElseIf Value = GraphicFormats.TIFF Then
_FileFormat = Imaging.ImageFormat.Tiff
End If
End Set
End Property
This way the object would really store in _FileFormat of type
Imaging.ImageFormat, 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.ImageFormat, 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?