diff --git a/COM350/Project1/Project1/FileData.vb b/COM350/Project1/Project1/FileData.vb new file mode 100644 index 0000000..d543c48 --- /dev/null +++ b/COM350/Project1/Project1/FileData.vb @@ -0,0 +1,35 @@ +Public Class FileData + + Sub New(fileName As String, fileTime As String) + Me.FileName = fileName + Me.FileTime = fileTime + End Sub + + Private _FileName As String + Public Property FileName() As String + Get + Return _FileName + End Get + Set(ByVal value As String) + _FileName = value + End Set + End Property + + Private _FileTime As Integer + Public Property FileTime() As Integer + Get + Return _FileTime + End Get + Set(ByVal value As Integer) + _FileTime = value + End Set + End Property + + Overrides Function ToString() As String + Dim out As String = Me.FileName & " - [" & Me.FileTime.ToString() & "]" + Return out + End Function + + + +End Class diff --git a/COM350/Project1/Project1/MainForm.Designer.vb b/COM350/Project1/Project1/MainForm.Designer.vb index 2161e5a..21148f1 100644 --- a/COM350/Project1/Project1/MainForm.Designer.vb +++ b/COM350/Project1/Project1/MainForm.Designer.vb @@ -23,21 +23,21 @@ Partial Class MainForm _ Private Sub InitializeComponent() Me.GroupBox1 = New System.Windows.Forms.GroupBox() + Me.Button4 = New System.Windows.Forms.Button() + Me.Button3 = New System.Windows.Forms.Button() + Me.Button2 = New System.Windows.Forms.Button() + Me.Button1 = New System.Windows.Forms.Button() + Me.Label3 = New System.Windows.Forms.Label() + Me.Label4 = New System.Windows.Forms.Label() + Me.Label2 = New System.Windows.Forms.Label() + Me.Label1 = New System.Windows.Forms.Label() + Me.ListBox2 = New System.Windows.Forms.ListBox() + Me.ListBox1 = New System.Windows.Forms.ListBox() Me.MenuStrip1 = New System.Windows.Forms.MenuStrip() Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.OptionsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.DefaultToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() - Me.ListBox1 = New System.Windows.Forms.ListBox() - Me.ListBox2 = New System.Windows.Forms.ListBox() - Me.Label1 = New System.Windows.Forms.Label() - Me.Label2 = New System.Windows.Forms.Label() - Me.Label3 = New System.Windows.Forms.Label() - Me.Label4 = New System.Windows.Forms.Label() - Me.Button1 = New System.Windows.Forms.Button() - Me.Button2 = New System.Windows.Forms.Button() - Me.Button3 = New System.Windows.Forms.Button() - Me.Button4 = New System.Windows.Forms.Button() Me.GroupBox1.SuspendLayout() Me.MenuStrip1.SuspendLayout() Me.SuspendLayout() @@ -62,78 +62,43 @@ Partial Class MainForm Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "MP3 Player" ' - 'MenuStrip1 + 'Button4 ' - Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem, Me.OptionsToolStripMenuItem}) - Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) - Me.MenuStrip1.Name = "MenuStrip1" - Me.MenuStrip1.Size = New System.Drawing.Size(686, 24) - Me.MenuStrip1.TabIndex = 1 - Me.MenuStrip1.Text = "MenuStrip1" + Me.Button4.Enabled = False + Me.Button4.Location = New System.Drawing.Point(311, 347) + Me.Button4.Name = "Button4" + Me.Button4.Size = New System.Drawing.Size(75, 23) + Me.Button4.TabIndex = 9 + Me.Button4.Text = "<" + Me.Button4.UseVisualStyleBackColor = True ' - 'FileToolStripMenuItem + 'Button3 ' - Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ExitToolStripMenuItem}) - Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" - Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 20) - Me.FileToolStripMenuItem.Text = "&File" + Me.Button3.Enabled = False + Me.Button3.Location = New System.Drawing.Point(311, 318) + Me.Button3.Name = "Button3" + Me.Button3.Size = New System.Drawing.Size(75, 23) + Me.Button3.TabIndex = 8 + Me.Button3.Text = "<<" + Me.Button3.UseVisualStyleBackColor = True ' - 'ExitToolStripMenuItem + 'Button2 ' - Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem" - Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(92, 22) - Me.ExitToolStripMenuItem.Text = "E&xit" + Me.Button2.Location = New System.Drawing.Point(311, 145) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(75, 23) + Me.Button2.TabIndex = 7 + Me.Button2.Text = ">>" + Me.Button2.UseVisualStyleBackColor = True ' - 'OptionsToolStripMenuItem + 'Button1 ' - Me.OptionsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DefaultToolStripMenuItem}) - Me.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem" - Me.OptionsToolStripMenuItem.Size = New System.Drawing.Size(61, 20) - Me.OptionsToolStripMenuItem.Text = "&Options" - ' - 'DefaultToolStripMenuItem - ' - Me.DefaultToolStripMenuItem.Name = "DefaultToolStripMenuItem" - Me.DefaultToolStripMenuItem.Size = New System.Drawing.Size(152, 22) - Me.DefaultToolStripMenuItem.Text = "&Default" - ' - 'ListBox1 - ' - Me.ListBox1.FormattingEnabled = True - Me.ListBox1.HorizontalScrollbar = True - Me.ListBox1.Location = New System.Drawing.Point(14, 79) - Me.ListBox1.Name = "ListBox1" - Me.ListBox1.ScrollAlwaysVisible = True - Me.ListBox1.Size = New System.Drawing.Size(269, 329) - Me.ListBox1.TabIndex = 0 - ' - 'ListBox2 - ' - Me.ListBox2.FormattingEnabled = True - Me.ListBox2.HorizontalScrollbar = True - Me.ListBox2.Location = New System.Drawing.Point(411, 79) - Me.ListBox2.Name = "ListBox2" - Me.ListBox2.ScrollAlwaysVisible = True - Me.ListBox2.Size = New System.Drawing.Size(263, 329) - Me.ListBox2.TabIndex = 1 - ' - 'Label1 - ' - Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(408, 60) - Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(71, 13) - Me.Label1.TabIndex = 2 - Me.Label1.Text = "Playlist Time: " - ' - 'Label2 - ' - Me.Label2.AutoSize = True - Me.Label2.Location = New System.Drawing.Point(485, 60) - Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(28, 13) - Me.Label2.TabIndex = 3 - Me.Label2.Text = "0:00" + Me.Button1.Location = New System.Drawing.Point(311, 116) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(75, 23) + Me.Button1.TabIndex = 6 + Me.Button1.Text = ">" + Me.Button1.UseVisualStyleBackColor = True ' 'Label3 ' @@ -153,43 +118,80 @@ Partial Class MainForm Me.Label4.TabIndex = 4 Me.Label4.Text = "Total Time: " ' - 'Button1 + 'Label2 ' - Me.Button1.Location = New System.Drawing.Point(311, 116) - Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(75, 23) - Me.Button1.TabIndex = 6 - Me.Button1.Text = ">" - Me.Button1.UseVisualStyleBackColor = True + Me.Label2.AutoSize = True + Me.Label2.Location = New System.Drawing.Point(485, 60) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(28, 13) + Me.Label2.TabIndex = 3 + Me.Label2.Text = "0:00" ' - 'Button2 + 'Label1 ' - Me.Button2.Location = New System.Drawing.Point(311, 145) - Me.Button2.Name = "Button2" - Me.Button2.Size = New System.Drawing.Size(75, 23) - Me.Button2.TabIndex = 7 - Me.Button2.Text = ">>" - Me.Button2.UseVisualStyleBackColor = True + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(408, 60) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(71, 13) + Me.Label1.TabIndex = 2 + Me.Label1.Text = "Playlist Time: " ' - 'Button3 + 'ListBox2 ' - Me.Button3.Enabled = False - Me.Button3.Location = New System.Drawing.Point(311, 318) - Me.Button3.Name = "Button3" - Me.Button3.Size = New System.Drawing.Size(75, 23) - Me.Button3.TabIndex = 8 - Me.Button3.Text = "<<" - Me.Button3.UseVisualStyleBackColor = True + Me.ListBox2.FormattingEnabled = True + Me.ListBox2.HorizontalScrollbar = True + Me.ListBox2.Location = New System.Drawing.Point(411, 79) + Me.ListBox2.Name = "ListBox2" + Me.ListBox2.ScrollAlwaysVisible = True + Me.ListBox2.Size = New System.Drawing.Size(263, 329) + Me.ListBox2.TabIndex = 1 ' - 'Button4 + 'ListBox1 ' - Me.Button4.Enabled = False - Me.Button4.Location = New System.Drawing.Point(311, 347) - Me.Button4.Name = "Button4" - Me.Button4.Size = New System.Drawing.Size(75, 23) - Me.Button4.TabIndex = 9 - Me.Button4.Text = "<" - Me.Button4.UseVisualStyleBackColor = True + Me.ListBox1.FormattingEnabled = True + Me.ListBox1.HorizontalScrollbar = True + Me.ListBox1.Location = New System.Drawing.Point(14, 79) + Me.ListBox1.Name = "ListBox1" + Me.ListBox1.ScrollAlwaysVisible = True + Me.ListBox1.Size = New System.Drawing.Size(269, 329) + Me.ListBox1.TabIndex = 0 + ' + 'MenuStrip1 + ' + Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem, Me.OptionsToolStripMenuItem}) + Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) + Me.MenuStrip1.Name = "MenuStrip1" + Me.MenuStrip1.Size = New System.Drawing.Size(686, 24) + Me.MenuStrip1.TabIndex = 1 + Me.MenuStrip1.Text = "MenuStrip1" + ' + 'FileToolStripMenuItem + ' + Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ExitToolStripMenuItem}) + Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem" + Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 20) + Me.FileToolStripMenuItem.Text = "&File" + ' + 'ExitToolStripMenuItem + ' + Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem" + Me.ExitToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.F4), System.Windows.Forms.Keys) + Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(152, 22) + Me.ExitToolStripMenuItem.Text = "E&xit" + ' + 'OptionsToolStripMenuItem + ' + Me.OptionsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DefaultToolStripMenuItem}) + Me.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem" + Me.OptionsToolStripMenuItem.Size = New System.Drawing.Size(61, 20) + Me.OptionsToolStripMenuItem.Text = "&Options" + ' + 'DefaultToolStripMenuItem + ' + Me.DefaultToolStripMenuItem.Name = "DefaultToolStripMenuItem" + Me.DefaultToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D), System.Windows.Forms.Keys) + Me.DefaultToolStripMenuItem.Size = New System.Drawing.Size(154, 22) + Me.DefaultToolStripMenuItem.Text = "&Default" ' 'MainForm ' diff --git a/COM350/Project1/Project1/MainForm.vb b/COM350/Project1/Project1/MainForm.vb index 7928628..33f39d4 100644 --- a/COM350/Project1/Project1/MainForm.vb +++ b/COM350/Project1/Project1/MainForm.vb @@ -1,18 +1,21 @@ Public Class MainForm + Protected list As New List(Of FileData) Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub Private Sub DefaultToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DefaultToolStripMenuItem.Click - Dim lnof = New OptionsForm(Me) - lnof.Show() + Dim lnof = New OptionsForm() + If (lnof.ShowDialog() = Windows.Forms.DialogResult.OK) Then + RefreshData() + End If End Sub - Public Sub SubFormCallback() - MessageBox.Show("Do we halt here", "I dunno", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + Public Sub RefreshData() + ' MessageBox.Show("Do we halt here", "I dunno", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) + For Each foundFile As String In My.Computer.FileSystem.GetFiles(Options.Directory) End Sub - End Class diff --git a/COM350/Project1/Project1/OptionsForm.Designer.vb b/COM350/Project1/Project1/OptionsForm.Designer.vb index bececa7..e2674b5 100644 --- a/COM350/Project1/Project1/OptionsForm.Designer.vb +++ b/COM350/Project1/Project1/OptionsForm.Designer.vb @@ -107,6 +107,7 @@ Partial Class OptionsForm ' 'Button2 ' + Me.Button2.DialogResult = System.Windows.Forms.DialogResult.OK Me.Button2.Location = New System.Drawing.Point(188, 142) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(75, 23) diff --git a/COM350/Project1/Project1/OptionsForm.vb b/COM350/Project1/Project1/OptionsForm.vb index 55e3295..4f72cd2 100644 --- a/COM350/Project1/Project1/OptionsForm.vb +++ b/COM350/Project1/Project1/OptionsForm.vb @@ -1,28 +1,19 @@ Public Class OptionsForm - Private CallbackForm As MainForm - - Sub New() - InitializeComponent() - End Sub - - Sub New(ByVal mainform As Form) - InitializeComponent() - CallbackForm = mainform - End Sub - - Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click - CallbackForm.SubFormCallback() Me.Close() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click - Options.Directory = TextBox1.Text - Options.SongGap = NumericUpDown1.Value - Options.PlaylistLength = 1 - CallbackForm.SubFormCallback() - Me.Close() + If My.Computer.FileSystem.DirectoryExists(TextBox1.Text) Then + Options.Directory = TextBox1.Text + Options.SongGap = NumericUpDown1.Value + Options.PlaylistLength = 1 + Me.Close() + Else + MessageBox.Show("Error, invalid path specified", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + End If + End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click @@ -30,4 +21,8 @@ TextBox1.Text = FolderBrowserDialog1.SelectedPath End If End Sub + + Private Sub OptionsForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load + TextBox1.Text = My.Computer.FileSystem.SpecialDirectories.MyMusic.ToString() + End Sub End Class \ No newline at end of file diff --git a/COM350/Project1/Project1/Project1.vbproj b/COM350/Project1/Project1/Project1.vbproj index ee95ddf..8dc8c4f 100644 --- a/COM350/Project1/Project1/Project1.vbproj +++ b/COM350/Project1/Project1/Project1.vbproj @@ -70,6 +70,7 @@ + Form