PageRenderTime 30ms CodeModel.GetById 8ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/PowerSong/Item Management/frmNotice.vb

#
Visual Basic | 91 lines | 62 code | 27 blank | 2 comment | 1 complexity | e9e544f7d8544036b1aed2752cef06c7 MD5 | raw file
 1Imports System.Windows.Forms
 2Imports PowerSong.Projection
 3Imports PowerSong.SongDatabase
 4
 5Public Class frmNotice
 6
 7    Private FNotice As Notice = Nothing
 8
 9    Public ReadOnly Property Notice() As Notice
10        Get
11            UpdateNotice()
12            Return FNotice
13        End Get
14    End Property
15
16    Private FDatabase As Database = Nothing
17
18    Public Sub New(ByVal database As Database)
19
20        InitializeComponent()
21
22        FDatabase = database
23
24        pbTextColour.BackColor = database.Settings.NoticeDefaultBackgroundColour
25        pbBackgroundColour.BackColor = database.Settings.NoticeDefaultFontColour
26        txtDuration.Value = database.Settings.NoticeDefaultDuration
27
28    End Sub
29
30    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
31
32        ' Validate the form
33        If txtContent.Text.Trim.Length = 0 Then
34            MsgBox("Please specify some content for the notice.", MsgBoxStyle.Information)
35            Exit Sub
36        End If
37
38        ' Close the form
39        Me.DialogResult = System.Windows.Forms.DialogResult.OK
40        Me.Close()
41
42    End Sub
43
44    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
45        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
46        Me.Close()
47    End Sub
48
49    Private Sub SelectTextColour(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectTextColour.Click, pbTextColour.Click
50
51        dlgSelectColour.Color = pbTextColour.BackColor
52        If dlgSelectColour.ShowDialog = Windows.Forms.DialogResult.OK Then
53            pbTextColour.BackColor = dlgSelectColour.Color
54        End If
55
56    End Sub
57
58    Private Sub SelectBackgroundColour(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectBackgroundColour.Click, pbBackgroundColour.Click
59
60        dlgSelectColour.Color = pbBackgroundColour.BackColor
61        If dlgSelectColour.ShowDialog = Windows.Forms.DialogResult.OK Then
62            pbBackgroundColour.BackColor = dlgSelectColour.Color
63        End If
64
65    End Sub
66
67    Private Sub UpdateNotice()
68
69        Dim BackgroundColour As Color = FDatabase.Settings.NoticeDefaultBackgroundColour
70        Dim ForegroundColour As Color = FDatabase.Settings.NoticeDefaultFontColour
71        Dim Duration As Integer = FDatabase.Settings.NoticeDefaultDuration
72
73        If chkOverrideSettings.Checked Then
74            BackgroundColour = pbBackgroundColour.BackColor
75            ForegroundColour = pbTextColour.BackColor
76            Duration = txtDuration.Value
77        End If
78
79        FNotice = New Notice(txtContent.Text, FDatabase.Settings.NoticeSpeed, Duration, BackgroundColour, ForegroundColour)
80        FNotice.Font = New Font(FDatabase.Settings.NoticeFontName, _
81                                FDatabase.Settings.NoticeFontSize, _
82                                FDatabase.Settings.NoticeFontStyle, _
83                                GraphicsUnit.Point)
84
85    End Sub
86
87    Private Sub chkOverrideSettings_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkOverrideSettings.CheckedChanged
88        pnlOverride.Enabled = chkOverrideSettings.Checked
89    End Sub
90
91End Class