PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/PowerSong/Styles/frmConfigureStyles.vb

#
Visual Basic | 63 lines | 48 code | 15 blank | 0 comment | 0 complexity | ed091797cbe8f4add006b0d0b794094f MD5 | raw file
 1Imports System.Windows.Forms
 2Imports PowerSong.SongDatabase
 3
 4Public Class frmConfigureStyles
 5
 6    Private FStyles As Styles
 7
 8    Public Sub New(ByVal styles As Styles)
 9        InitializeComponent()
10        FStyles = styles
11        UpdateList()
12    End Sub
13
14    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
15        Me.DialogResult = System.Windows.Forms.DialogResult.OK
16        Me.Close()
17    End Sub
18
19    Private Sub UpdateList()
20        lstStyles.Items.Clear()
21        For Each Style As Style In FStyles.GetAllStyles
22            lstStyles.Items.Add(New ListItem(Of Guid)(Style.Name, Style.StyleID))
23        Next
24    End Sub
25
26    Private Sub btnAddStyle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddStyle.Click
27        If (New frmNewStyle(FStyles)).ShowDialog = Windows.Forms.DialogResult.OK Then
28            UpdateList()
29            UpdateControls()
30        End If
31    End Sub
32
33    Private Sub btnDeleteStyle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteStyle.Click
34
35        Dim StyleID As Guid = DirectCast(lstStyles.SelectedItem, ListItem(Of Guid)).Key
36        If MsgBox("Are you sure you wish to delete the style '" + FStyles.GetStyle(StyleID).Name + "'?", MsgBoxStyle.Question + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
37            FStyles.DeleteStyle(StyleID)
38            lstStyles.Items.RemoveAt(lstStyles.SelectedIndex)
39            UpdateControls()
40        End If
41
42    End Sub
43
44    Private Sub btnEditStyle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditStyle.Click
45
46        Dim StyleID As Guid = DirectCast(lstStyles.SelectedItem, ListItem(Of Guid)).Key
47        If New frmEditStyle(FStyles.GetStyle(StyleID), FStyles).ShowDialog = Windows.Forms.DialogResult.OK Then
48            UpdateList()
49            UpdateControls()
50        End If
51
52    End Sub
53
54    Private Sub lstStyles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstStyles.SelectedIndexChanged
55        UpdateControls()
56    End Sub
57
58    Private Sub UpdateControls()
59        btnDeleteStyle.Enabled = lstStyles.SelectedIndex > -1
60        btnEditStyle.Enabled = lstStyles.SelectedIndex > -1
61    End Sub
62
63End Class