Project 1 VB 04/01/2015
Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
This commit is contained in:
1 parent
6dd63cc439
commit
6d88507dd9
6 files changed
+182
-19
No files matched your search
@@ -1,6 +1,6 @@
|
||||
Public Class FileData
|
||||
|
||||
Sub New(fileName As String, fileTime As String)
|
||||
Sub New(fileName As String, fileTime As Integer)
|
||||
Me.FileName = fileName
|
||||
Me.FileTime = fileTime
|
||||
End Sub
|
||||
@@ -26,7 +26,19 @@
|
||||
End Property
|
||||
|
||||
Overrides Function ToString() As String
|
||||
Dim out As String = Me.FileName & " - [" & Me.FileTime.ToString() & "]"
|
||||
Dim formattedTime As String = String.Empty
|
||||
Dim iSpan As TimeSpan = TimeSpan.FromSeconds(Me.FileTime)
|
||||
If iSpan.Hours > 0 Then
|
||||
formattedTime = iSpan.Hours.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
Else
|
||||
formattedTime = iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
End If
|
||||
|
||||
Dim out As String = Me.FileName & " - [" & formattedTime & "]"
|
||||
|
||||
Return out
|
||||
End Function
|
||||
|
||||
|
||||
+29
-3
@@ -23,6 +23,8 @@ Partial Class MainForm
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
|
||||
Me.Label6 = New System.Windows.Forms.Label()
|
||||
Me.Label5 = New System.Windows.Forms.Label()
|
||||
Me.Button4 = New System.Windows.Forms.Button()
|
||||
Me.Button3 = New System.Windows.Forms.Button()
|
||||
Me.Button2 = New System.Windows.Forms.Button()
|
||||
@@ -44,6 +46,8 @@ Partial Class MainForm
|
||||
'
|
||||
'GroupBox1
|
||||
'
|
||||
Me.GroupBox1.Controls.Add(Me.Label6)
|
||||
Me.GroupBox1.Controls.Add(Me.Label5)
|
||||
Me.GroupBox1.Controls.Add(Me.Button4)
|
||||
Me.GroupBox1.Controls.Add(Me.Button3)
|
||||
Me.GroupBox1.Controls.Add(Me.Button2)
|
||||
@@ -62,6 +66,24 @@ Partial Class MainForm
|
||||
Me.GroupBox1.TabStop = False
|
||||
Me.GroupBox1.Text = "MP3 Player"
|
||||
'
|
||||
'Label6
|
||||
'
|
||||
Me.Label6.AutoSize = True
|
||||
Me.Label6.Location = New System.Drawing.Point(392, 27)
|
||||
Me.Label6.Name = "Label6"
|
||||
Me.Label6.Size = New System.Drawing.Size(34, 13)
|
||||
Me.Label6.TabIndex = 11
|
||||
Me.Label6.Text = "00:00"
|
||||
'
|
||||
'Label5
|
||||
'
|
||||
Me.Label5.AutoSize = True
|
||||
Me.Label5.Location = New System.Drawing.Point(266, 27)
|
||||
Me.Label5.Name = "Label5"
|
||||
Me.Label5.Size = New System.Drawing.Size(120, 13)
|
||||
Me.Label5.TabIndex = 10
|
||||
Me.Label5.Text = "Desired Playlist Length: "
|
||||
'
|
||||
'Button4
|
||||
'
|
||||
Me.Button4.Enabled = False
|
||||
@@ -84,6 +106,7 @@ Partial Class MainForm
|
||||
'
|
||||
'Button2
|
||||
'
|
||||
Me.Button2.Enabled = False
|
||||
Me.Button2.Location = New System.Drawing.Point(311, 145)
|
||||
Me.Button2.Name = "Button2"
|
||||
Me.Button2.Size = New System.Drawing.Size(75, 23)
|
||||
@@ -93,6 +116,7 @@ Partial Class MainForm
|
||||
'
|
||||
'Button1
|
||||
'
|
||||
Me.Button1.Enabled = False
|
||||
Me.Button1.Location = New System.Drawing.Point(311, 116)
|
||||
Me.Button1.Name = "Button1"
|
||||
Me.Button1.Size = New System.Drawing.Size(75, 23)
|
||||
@@ -121,7 +145,7 @@ Partial Class MainForm
|
||||
'Label2
|
||||
'
|
||||
Me.Label2.AutoSize = True
|
||||
Me.Label2.Location = New System.Drawing.Point(485, 60)
|
||||
Me.Label2.Location = New System.Drawing.Point(646, 60)
|
||||
Me.Label2.Name = "Label2"
|
||||
Me.Label2.Size = New System.Drawing.Size(28, 13)
|
||||
Me.Label2.TabIndex = 3
|
||||
@@ -130,7 +154,7 @@ Partial Class MainForm
|
||||
'Label1
|
||||
'
|
||||
Me.Label1.AutoSize = True
|
||||
Me.Label1.Location = New System.Drawing.Point(408, 60)
|
||||
Me.Label1.Location = New System.Drawing.Point(569, 60)
|
||||
Me.Label1.Name = "Label1"
|
||||
Me.Label1.Size = New System.Drawing.Size(71, 13)
|
||||
Me.Label1.TabIndex = 2
|
||||
@@ -176,7 +200,7 @@ Partial Class MainForm
|
||||
'
|
||||
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.Size = New System.Drawing.Size(134, 22)
|
||||
Me.ExitToolStripMenuItem.Text = "E&xit"
|
||||
'
|
||||
'OptionsToolStripMenuItem
|
||||
@@ -228,5 +252,7 @@ Partial Class MainForm
|
||||
Friend WithEvents Button3 As System.Windows.Forms.Button
|
||||
Friend WithEvents Button2 As System.Windows.Forms.Button
|
||||
Friend WithEvents Button1 As System.Windows.Forms.Button
|
||||
Friend WithEvents Label6 As System.Windows.Forms.Label
|
||||
Friend WithEvents Label5 As System.Windows.Forms.Label
|
||||
|
||||
End Class
|
||||
@@ -1,6 +1,8 @@
|
||||
Public Class MainForm
|
||||
|
||||
Protected list As New List(Of FileData)
|
||||
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
|
||||
Application.Exit()
|
||||
@@ -13,11 +15,137 @@
|
||||
End If
|
||||
End Sub
|
||||
|
||||
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)
|
||||
|
||||
Next
|
||||
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
|
||||
If ListBox1.SelectedIndex >= 0 Then
|
||||
Button1.Enabled = True
|
||||
Else
|
||||
Button1.Enabled = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ListBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox2.SelectedIndexChanged
|
||||
If ListBox2.SelectedIndex >= 0 Then
|
||||
Button4.Enabled = True
|
||||
Else
|
||||
Button4.Enabled = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||
Dim file As FileData = ListBox1.Items(ListBox1.SelectedIndex)
|
||||
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
|
||||
RemoveFileFromTotal(file)
|
||||
ListBox2.Items.Add(file)
|
||||
AddFileToPlaylist(file)
|
||||
End Sub
|
||||
|
||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||
Button1.Enabled = False
|
||||
Button2.Enabled = False
|
||||
End Sub
|
||||
|
||||
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
||||
Button3.Enabled = False
|
||||
Button4.Enabled = False
|
||||
End Sub
|
||||
|
||||
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
|
||||
Dim file As FileData = ListBox2.Items(ListBox2.SelectedIndex)
|
||||
ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
|
||||
RemoveFileFromPlaylist(file)
|
||||
ListBox1.Items.Add(file)
|
||||
AddFileToTotal(file)
|
||||
End Sub
|
||||
|
||||
|
||||
Public Sub RefreshData()
|
||||
' MessageBox.Show("Do we halt here", "I dunno", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Options.TotalTime = 0
|
||||
Options.PlaylistTime = 0
|
||||
AddFileToTotal(New FileData("", 0))
|
||||
AddFileToPlaylist(New FileData("", 0))
|
||||
|
||||
ListBox1.Items.Clear()
|
||||
ListBox2.Items.Clear()
|
||||
|
||||
Label6.Text = Options.PlaylistLength
|
||||
|
||||
For Each foundFile As String In My.Computer.FileSystem.GetFiles(Options.Directory)
|
||||
foundFile = My.Computer.FileSystem.GetName(foundFile)
|
||||
Dim foundExt = System.IO.Path.GetExtension(foundFile)
|
||||
For Each lext As String In Options.ExtensionsList
|
||||
If foundExt = lext Then
|
||||
Dim randomTime As Integer = CInt(Int(((6 * 60) * Rnd()) + 60))
|
||||
Dim file As New FileData(foundFile, randomTime)
|
||||
ListBox1.Items.Add(file)
|
||||
AddFileToTotal(file)
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
If ListBox1.Items.Count > 0 Then
|
||||
Button2.Enabled = True
|
||||
Else
|
||||
Button2.Enabled = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub AddFileToTotal(file As FileData)
|
||||
Options.TotalTime += file.FileTime
|
||||
Dim formattedTime As String = String.Empty
|
||||
Dim iSpan As TimeSpan = TimeSpan.FromSeconds(Options.TotalTime)
|
||||
If iSpan.Hours > 0 Then
|
||||
formattedTime = iSpan.Hours.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
Else
|
||||
formattedTime = iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
End If
|
||||
Label3.Text = formattedTime
|
||||
End Sub
|
||||
|
||||
Private Sub RemoveFileFromTotal(file As FileData)
|
||||
Options.TotalTime -= file.FileTime
|
||||
Dim formattedTime As String = String.Empty
|
||||
Dim iSpan As TimeSpan = TimeSpan.FromSeconds(Options.TotalTime)
|
||||
If iSpan.Hours > 0 Then
|
||||
formattedTime = iSpan.Hours.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
Else
|
||||
formattedTime = iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
End If
|
||||
Label3.Text = formattedTime
|
||||
End Sub
|
||||
|
||||
Private Sub AddFileToPlaylist(file As FileData)
|
||||
Options.PlaylistTime += file.FileTime
|
||||
Dim formattedTime As String = String.Empty
|
||||
Dim iSpan As TimeSpan = TimeSpan.FromSeconds(Options.PlaylistTime)
|
||||
If iSpan.Hours > 0 Then
|
||||
formattedTime = iSpan.Hours.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
Else
|
||||
formattedTime = iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
End If
|
||||
Label2.Text = formattedTime
|
||||
End Sub
|
||||
|
||||
Private Sub RemoveFileFromPlaylist(file As FileData)
|
||||
Options.PlaylistTime -= file.FileTime
|
||||
Dim formattedTime As String = String.Empty
|
||||
Dim iSpan As TimeSpan = TimeSpan.FromSeconds(Options.PlaylistTime)
|
||||
If iSpan.Hours > 0 Then
|
||||
formattedTime = iSpan.Hours.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
Else
|
||||
formattedTime = iSpan.Minutes.ToString.PadLeft(2, "0"c) & ":" & _
|
||||
iSpan.Seconds.ToString.PadLeft(2, "0"c)
|
||||
End If
|
||||
Label2.Text = formattedTime
|
||||
End Sub
|
||||
End Class
|
||||
@@ -30,13 +30,9 @@
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Files As List(Of FileData)
|
||||
Sub AddFile(in as String)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public ExtensionsList As String() = {".3gp", ".act", ".aiff", ".aac", ".amr", ".au", ".awb", ".dct", ".dss", ".dvf", ".flac", ".gsm", ".iklax", ".ivs", ".m4a", ".m4p", ".mmf", ".mp3", ".mpc", ".msv", ".ogg", ".oga", ".opus", ".ra", ".rm", ".raw", ".sln", ".tta", ".vox", ".wav", ".wma", ".wv"}
|
||||
|
||||
Public PlaylistTime As Integer = 0
|
||||
Public TotalTime As Integer = 0
|
||||
|
||||
End Module
|
||||
+1
-1
@@ -134,7 +134,7 @@ Partial Class OptionsForm
|
||||
Me.DateTimePicker1.ShowUpDown = True
|
||||
Me.DateTimePicker1.Size = New System.Drawing.Size(75, 20)
|
||||
Me.DateTimePicker1.TabIndex = 11
|
||||
Me.DateTimePicker1.Value = New Date(2015, 3, 31, 0, 20, 0, 0)
|
||||
Me.DateTimePicker1.Value = New Date(1753, 1, 1, 0, 20, 0, 0)
|
||||
'
|
||||
'FolderBrowserDialog1
|
||||
'
|
||||
|
||||
Submodule
+1
Submodule COM350/WinForm added at 18f319396c.
Reference in new issue
Block a user