diff --git a/SLAM/Form1.Designer.vb b/SLAM/Form1.Designer.vb index 985017c..b8b7642 100644 --- a/SLAM/Form1.Designer.vb +++ b/SLAM/Form1.Designer.vb @@ -45,6 +45,7 @@ Partial Class Form1 Me.GoToToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ContextRefresh = New System.Windows.Forms.ToolStripMenuItem() Me.RemoveHotkeyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.RenameToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.ContextHotKey = New System.Windows.Forms.ToolStripMenuItem() Me.SetVolumeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.TrimToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() @@ -177,9 +178,9 @@ Partial Class Form1 ' 'TrackContextMenu ' - Me.TrackContextMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContextDelete, Me.GoToToolStripMenuItem, Me.ContextRefresh, Me.RemoveHotkeyToolStripMenuItem, Me.ContextHotKey, Me.SetVolumeToolStripMenuItem, Me.TrimToolStripMenuItem}) + Me.TrackContextMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContextDelete, Me.GoToToolStripMenuItem, Me.ContextRefresh, Me.RemoveHotkeyToolStripMenuItem, Me.RenameToolStripMenuItem, Me.ContextHotKey, Me.SetVolumeToolStripMenuItem, Me.TrimToolStripMenuItem}) Me.TrackContextMenu.Name = "TrackContextMenu" - Me.TrackContextMenu.Size = New System.Drawing.Size(145, 158) + Me.TrackContextMenu.Size = New System.Drawing.Size(145, 180) ' 'ContextDelete ' @@ -205,6 +206,12 @@ Partial Class Form1 Me.RemoveHotkeyToolStripMenuItem.Size = New System.Drawing.Size(144, 22) Me.RemoveHotkeyToolStripMenuItem.Text = "Remove Bind" ' + 'RenameToolStripMenuItem + ' + Me.RenameToolStripMenuItem.Name = "RenameToolStripMenuItem" + Me.RenameToolStripMenuItem.Size = New System.Drawing.Size(144, 22) + Me.RenameToolStripMenuItem.Text = "Rename" + ' 'ContextHotKey ' Me.ContextHotKey.Name = "ContextHotKey" @@ -293,4 +300,5 @@ Partial Class Form1 Friend WithEvents TrimToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem Friend WithEvents Trimmed As System.Windows.Forms.ColumnHeader Friend WithEvents StatusLabel As System.Windows.Forms.Label + Friend WithEvents RenameToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem End Class diff --git a/SLAM/Form1.vb b/SLAM/Form1.vb index bffd7ec..de4bff9 100644 --- a/SLAM/Form1.vb +++ b/SLAM/Form1.vb @@ -8,7 +8,6 @@ Imports SLAM.SourceGame Imports System.Management Imports System.Net.Http - Public Class Form1 Dim Games As New List(Of SourceGame) @@ -834,6 +833,39 @@ Public Class Form1 End If End Sub + Private Sub RenameToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RenameToolStripMenuItem.Click + Dim Game As SourceGame = GetCurrentGame() + Dim RenameDialog As New RenameForm + Dim SelectedTrack As SourceGame.track = GetCurrentGame.tracks(TrackList.SelectedIndices(0)) + + RenameDialog.filename = SelectedTrack.name + + If RenameDialog.ShowDialog = Windows.Forms.DialogResult.OK Then + Try + + FileSystem.Rename(Game.libraryname & SelectedTrack.name & Game.FileExtension, Game.libraryname & RenameDialog.filename & Game.FileExtension) + GetCurrentGame.tracks(TrackList.SelectedIndices(0)).name = RenameDialog.filename + + SaveTrackKeys(GetCurrentGame) + ReloadTracks(GetCurrentGame) + RefreshTrackList() + + Catch ex As Exception + Select Case ex.HResult + Case -2147024809 + MessageBox.Show("""" & RenameDialog.filename & """ contains invalid characters.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + + Case -2146232800 + MessageBox.Show("A track with that name already exists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + + Case Else + MessageBox.Show(ex.Message & " See errorlog.txt for more info.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + End Select + + End Try + End If + End Sub + Private Async Sub CheckForUpdate() Dim UpdateText As String diff --git a/SLAM/RenameForm.Designer.vb b/SLAM/RenameForm.Designer.vb new file mode 100644 index 0000000..2bebc46 --- /dev/null +++ b/SLAM/RenameForm.Designer.vb @@ -0,0 +1,74 @@ + _ +Partial Class RenameForm + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.NameBox = New System.Windows.Forms.TextBox() + Me.DoneButton = New System.Windows.Forms.Button() + Me.Label1 = New System.Windows.Forms.Label() + Me.SuspendLayout() + ' + 'NameBox + ' + Me.NameBox.Location = New System.Drawing.Point(79, 12) + Me.NameBox.Name = "NameBox" + Me.NameBox.Size = New System.Drawing.Size(183, 20) + Me.NameBox.TabIndex = 0 + ' + 'DoneButton + ' + Me.DoneButton.Location = New System.Drawing.Point(268, 10) + Me.DoneButton.Name = "DoneButton" + Me.DoneButton.Size = New System.Drawing.Size(75, 23) + Me.DoneButton.TabIndex = 1 + Me.DoneButton.Text = "Done" + Me.DoneButton.UseVisualStyleBackColor = True + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(12, 15) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(61, 13) + Me.Label1.TabIndex = 2 + Me.Label1.Text = "New name:" + ' + 'RenameForm + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(355, 42) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.DoneButton) + Me.Controls.Add(Me.NameBox) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.Name = "RenameForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Rename" + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + Friend WithEvents NameBox As System.Windows.Forms.TextBox + Friend WithEvents DoneButton As System.Windows.Forms.Button + Friend WithEvents Label1 As System.Windows.Forms.Label +End Class diff --git a/SLAM/RenameForm.resx b/SLAM/RenameForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SLAM/RenameForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SLAM/RenameForm.vb b/SLAM/RenameForm.vb new file mode 100644 index 0000000..a5861b3 --- /dev/null +++ b/SLAM/RenameForm.vb @@ -0,0 +1,17 @@ +Public Class RenameForm + + Public filename As String + + Private Sub DoneButton_Click(sender As Object, e As EventArgs) Handles DoneButton.Click + If String.IsNullOrWhiteSpace(NameBox.Text) Then + MessageBox.Show("The name can not be empty.", "Naming Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + Else + filename = NameBox.Text + DialogResult = Windows.Forms.DialogResult.OK + End If + End Sub + + Private Sub RenameForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load + NameBox.Text = filename + End Sub +End Class \ No newline at end of file diff --git a/SLAM/SLAM.vbproj b/SLAM/SLAM.vbproj index 33e2f4e..f1e8aaa 100644 --- a/SLAM/SLAM.vbproj +++ b/SLAM/SLAM.vbproj @@ -105,6 +105,12 @@ Form1.vb Form + + RenameForm.vb + + + Form + SettingsForm.vb @@ -155,6 +161,9 @@ Form1.vb Designer + + RenameForm.vb + SettingsForm.vb