PageRenderTime 33ms CodeModel.GetById 1ms RepoModel.GetById 0ms 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
  1. Imports PowerSong.SongDatabase
  2. Imports PowerSong.SongDatabase.Items
  3. Public Class frmConfigureItem
  4. Private FItem As BaseItem = Nothing
  5. Private FStyles As Styles = Nothing
  6. Private FSelectedStyle As Style = Nothing
  7. Public Sub New(ByVal item As BaseItem, _
  8. ByVal itemStyle As Style, _
  9. ByVal styles As Styles)
  10. InitializeComponent()
  11. FItem = item
  12. FSelectedStyle = itemStyle
  13. FStyles = styles
  14. UpdateStyleList()
  15. Functionality.ConfigureForm(Me)
  16. End Sub
  17. Public ReadOnly Property SelectedStyle() As Style
  18. Get
  19. Return FSelectedStyle
  20. End Get
  21. End Property
  22. Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
  23. Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
  24. Me.Close()
  25. End Sub
  26. Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
  27. ' Close the form
  28. Me.DialogResult = System.Windows.Forms.DialogResult.OK
  29. Me.Close()
  30. End Sub
  31. Private Sub btnConfigureStyles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfigureStyles.Click
  32. If (New frmConfigureStyles(FStyles)).ShowDialog = Windows.Forms.DialogResult.OK Then
  33. UpdateStyleList()
  34. End If
  35. End Sub
  36. Private Sub UpdateStyleList()
  37. lstStyles.Items.Clear()
  38. For Each Style As Style In FStyles.GetAllStyles
  39. Dim Item As New ListItem(Of Guid)(Style.Name, Style.StyleID)
  40. lstStyles.Items.Add(Item)
  41. If Style Is FSelectedStyle Then lstStyles.SelectedItem = Item
  42. Next
  43. End Sub
  44. Private Sub lstStyles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstStyles.SelectedIndexChanged
  45. If lstStyles.SelectedItem IsNot Nothing Then
  46. Dim SelectedItem As ListItem(Of Guid) = lstStyles.SelectedItem
  47. FSelectedStyle = FStyles.GetStyle(SelectedItem.Key)
  48. End If
  49. End Sub
  50. End Class