PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Visual Basic | 66 lines | 49 code | 16 blank | 1 comment | 0 complexity | cc8d284cf60e0fe9f58d088e52e28ba6 MD5 | raw file
 1Imports PowerSong.SongDatabase
 2Imports PowerSong.SongDatabase.Items
 3
 4Public Class frmConfigureItem
 5
 6    Private FItem As BaseItem = Nothing
 7    Private FStyles As Styles = Nothing
 8    Private FSelectedStyle As Style = Nothing
 9
10    Public Sub New(ByVal item As BaseItem, _
11                   ByVal itemStyle As Style, _
12                   ByVal styles As Styles)
13
14        InitializeComponent()
15        FItem = item
16        FSelectedStyle = itemStyle
17        FStyles = styles
18        UpdateStyleList()
19        Functionality.ConfigureForm(Me)
20
21    End Sub
22
23    Public ReadOnly Property SelectedStyle() As Style
24        Get
25            Return FSelectedStyle
26        End Get
27    End Property
28
29    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
30        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
31        Me.Close()
32    End Sub
33
34    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
35
36        ' Close the form
37        Me.DialogResult = System.Windows.Forms.DialogResult.OK
38        Me.Close()
39
40    End Sub
41
42    Private Sub btnConfigureStyles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfigureStyles.Click
43        If (New frmConfigureStyles(FStyles)).ShowDialog = Windows.Forms.DialogResult.OK Then
44            UpdateStyleList()
45        End If
46    End Sub
47
48    Private Sub UpdateStyleList()
49        lstStyles.Items.Clear()
50        For Each Style As Style In FStyles.GetAllStyles
51            Dim Item As New ListItem(Of Guid)(Style.Name, Style.StyleID)
52            lstStyles.Items.Add(Item)
53            If Style Is FSelectedStyle Then lstStyles.SelectedItem = Item
54        Next
55    End Sub
56
57    Private Sub lstStyles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstStyles.SelectedIndexChanged
58
59        If lstStyles.SelectedItem IsNot Nothing Then
60            Dim SelectedItem As ListItem(Of Guid) = lstStyles.SelectedItem
61            FSelectedStyle = FStyles.GetStyle(SelectedItem.Key)
62        End If
63
64    End Sub
65
66End Class