|
Imports System.IO
Imports System.Text
Imports System.Drawing
Imports System.Reflection
Imports System.Drawing.Image
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic.ControlChars
Imports System.Net
Public MustInherit Class Theme
Private sFrmBackGroundImage As String
Private sFrmTransperncyColor As Color
Public Property BackGroundImage()
Get
Return sFrmBackGroundImage
End Get
Set(ByVal Value)
sFrmBackGroundImage = Value
End Set
End Property
Public Property TransperncyColor()
Get
Return sFrmTransperncyColor
End Get
Set(ByVal Value)
sFrmTransperncyColor = Value
End Set
End Property
Public MustOverride Function SetTheme(ByRef frmObj As Form) As Boolean
End Class
Public Class Theme1
Inherits Theme
Sub New()
'Get the Image Location
Dim fn As String = System.Environment.CurrentDirectory() & "\" & "Bitmap1.JPG"
Me.BackGroundImage = fn ' New Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("SampleMlaProjectWork.Bitmap1.JPG")) ' fn
Me.TransperncyColor = Color.FromArgb(192, 192, 255)
End Sub
Public Overrides Function SetTheme(ByRef frmObj As System.Windows.Forms.Form) As Boolean
'set the transparency color
frmObj.TransparencyKey = Me.TransperncyColor
'set the form background image
frmObj.BackgroundImage.FromFile(Me.BackGroundImage)
'Change the control settings
Dim cntl As Control
For Each cntl In frmObj.Controls
If TypeOf (cntl) Is Label Then
cntl.ForeColor = Color.White
cntl.BackColor = Color.Transparent
ElseIf TypeOf (cntl) Is ComboBox Then
cntl.ForeColor = Color.White
Else
cntl.ForeColor = Color.White
End If
Next
End Function
End Class
Public Class Theme2
Inherits Theme
Sub New()
'Get the Image Location
Dim fn As String = System.Environment.CurrentDirectory() & "\" & "Bitmap2.JPG"
Me.BackGroundImage = fn
Me.TransperncyColor = Color.FromArgb(192, 192, 255)
End Sub
Public Overrides Function SetTheme(ByRef frmObj As System.Windows.Forms.Form) As Boolean
'set the transparency color
frmObj.TransparencyKey = Me.TransperncyColor
'set the form background image
frmObj.BackgroundImage.FromFile(Me.BackGroundImage)
'Change the control settings
Dim cntl As Control
For Each cntl In frmObj.Controls
If TypeOf (cntl) Is Label Then
cntl.ForeColor = Color.Green
cntl.BackColor = Color.Gold
ElseIf TypeOf (cntl) Is ComboBox Then
cntl.ForeColor = Color.DarkRed
Else
cntl.ForeColor = Color.DarkGreen
End If
Next
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.