From 96a85cff677b23edf3322bc79be93408fc577587 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 19 Dec 2023 13:02:53 +0100 Subject: [PATCH] Weitere Umstrukturierung --- UltraStarSongPicker/FileFunctions.vb | 2 + UltraStarSongPicker/Objects/Song.vb | 2 +- .../Repositories/SongRepository.vb | 17 +- UltraStarSongPicker/frmMain.Designer.vb | 180 +++++++++--------- UltraStarSongPicker/frmMain.vb | 76 +++++--- 5 files changed, 157 insertions(+), 120 deletions(-) diff --git a/UltraStarSongPicker/FileFunctions.vb b/UltraStarSongPicker/FileFunctions.vb index 7a077db..8cad27e 100644 --- a/UltraStarSongPicker/FileFunctions.vb +++ b/UltraStarSongPicker/FileFunctions.vb @@ -1,6 +1,8 @@ Imports System.IO Friend Class FileFunctions + + Friend Shared Sub CopyDirectory(ByVal sourceDir As String, ByVal destinationDir As String, Optional ByVal recursive As Boolean = True) Dim dir = New DirectoryInfo(sourceDir) If Not dir.Exists Then Throw New DirectoryNotFoundException($"Source directory not found: {dir.FullName}") diff --git a/UltraStarSongPicker/Objects/Song.vb b/UltraStarSongPicker/Objects/Song.vb index 28559cc..23f5402 100644 --- a/UltraStarSongPicker/Objects/Song.vb +++ b/UltraStarSongPicker/Objects/Song.vb @@ -24,7 +24,7 @@ Public Class Song Public Property InfoFile As String Public Property HasError As Boolean Public Property ErrorText As String - Public Property ExistsInFavDir As Boolean + Public Property ExistsInUltrastar As Boolean Public ReadOnly Property SongInfoCount As Integer diff --git a/UltraStarSongPicker/Repositories/SongRepository.vb b/UltraStarSongPicker/Repositories/SongRepository.vb index c9fd3bf..3d52240 100644 --- a/UltraStarSongPicker/Repositories/SongRepository.vb +++ b/UltraStarSongPicker/Repositories/SongRepository.vb @@ -1,16 +1,23 @@ -Imports System.Data.Common +Imports System.ComponentModel +Imports System.Data.Common Imports System.Data.SQLite Imports DevExpress.Text Public Class SongRepository + Implements System.ComponentModel.IChangeTracking + Public ReadOnly Property IsChanged As Boolean Implements IChangeTracking.IsChanged + Get + Throw New NotImplementedException() + End Get + End Property - Friend Shared Async Function GetSongs() As Task(Of List(Of Song)) + Friend Shared Async Function GetSongs() As Task(Of BindingList(Of Song)) Dim con = DB.getConnection Dim cmd As New SQLiteCommand(Nothing, con) Dim reader As DbDataReader Await con.OpenAsync - Dim result As New List(Of Song) + Dim result As New BindingList(Of Song) cmd.CommandText = "SELECT * FROM t_songs" reader = Await cmd.ExecuteReaderAsync result.Clear() @@ -128,4 +135,8 @@ Public Class SongRepository Next con.Close() End Sub + + Public Sub AcceptChanges() Implements IChangeTracking.AcceptChanges + Throw New NotImplementedException() + End Sub End Class diff --git a/UltraStarSongPicker/frmMain.Designer.vb b/UltraStarSongPicker/frmMain.Designer.vb index 4f42fc6..4c104ed 100644 --- a/UltraStarSongPicker/frmMain.Designer.vb +++ b/UltraStarSongPicker/frmMain.Designer.vb @@ -29,26 +29,26 @@ Partial Class frmMain Me.btnReread = New DevExpress.XtraBars.BarButtonItem() Me.btnSave = New DevExpress.XtraBars.BarButtonItem() Me.btnPrint = New DevExpress.XtraBars.BarButtonItem() + Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem() Me.rpGeneral = New DevExpress.XtraBars.Ribbon.RibbonPage() Me.rpgGeneral = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.rpgManagement = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() + Me.rpgPlaylists = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() Me.grdSongs = New DevExpress.XtraGrid.GridControl() Me.cmsSongs = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.menOpenFolder = New System.Windows.Forms.ToolStripMenuItem() Me.menCopy = New System.Windows.Forms.ToolStripMenuItem() Me.grdvSongs = New DevExpress.XtraGrid.Views.Grid.GridView() Me.splMain = New DevExpress.XtraEditors.SplitContainerControl() + Me.splLibraryPlaylists = New DevExpress.XtraEditors.SplitContainerControl() + Me.grdPlaylist = New DevExpress.XtraGrid.GridControl() + Me.grdvPlaylist = New DevExpress.XtraGrid.Views.Grid.GridView() Me.prgMain = New DevExpress.XtraWaitForm.ProgressPanel() Me.splSongInfo = New DevExpress.XtraEditors.SplitContainerControl() Me.avPlayer = New UltraStarSongPicker.AudioVideoPlayer() Me.grdSongInfos = New DevExpress.XtraGrid.GridControl() Me.grdvSongInfos = New DevExpress.XtraGrid.Views.Grid.GridView() Me.SFD = New System.Windows.Forms.SaveFileDialog() - Me.splLibraryPlaylists = New DevExpress.XtraEditors.SplitContainerControl() - Me.grdPlaylist = New DevExpress.XtraGrid.GridControl() - Me.grdvPlaylist = New DevExpress.XtraGrid.Views.Grid.GridView() - Me.rpgPlaylists = New DevExpress.XtraBars.Ribbon.RibbonPageGroup() - Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem() CType(Me.rcMain, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.grdSongs, System.ComponentModel.ISupportInitialize).BeginInit() Me.cmsSongs.SuspendLayout() @@ -59,14 +59,6 @@ Partial Class frmMain CType(Me.splMain.Panel2, System.ComponentModel.ISupportInitialize).BeginInit() Me.splMain.Panel2.SuspendLayout() Me.splMain.SuspendLayout() - CType(Me.splSongInfo, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.splSongInfo.Panel1, System.ComponentModel.ISupportInitialize).BeginInit() - Me.splSongInfo.Panel1.SuspendLayout() - CType(Me.splSongInfo.Panel2, System.ComponentModel.ISupportInitialize).BeginInit() - Me.splSongInfo.Panel2.SuspendLayout() - Me.splSongInfo.SuspendLayout() - CType(Me.grdSongInfos, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.grdvSongInfos, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.splLibraryPlaylists, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.splLibraryPlaylists.Panel1, System.ComponentModel.ISupportInitialize).BeginInit() Me.splLibraryPlaylists.Panel1.SuspendLayout() @@ -75,6 +67,14 @@ Partial Class frmMain Me.splLibraryPlaylists.SuspendLayout() CType(Me.grdPlaylist, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.grdvPlaylist, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.splSongInfo, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.splSongInfo.Panel1, System.ComponentModel.ISupportInitialize).BeginInit() + Me.splSongInfo.Panel1.SuspendLayout() + CType(Me.splSongInfo.Panel2, System.ComponentModel.ISupportInitialize).BeginInit() + Me.splSongInfo.Panel2.SuspendLayout() + Me.splSongInfo.SuspendLayout() + CType(Me.grdSongInfos, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.grdvSongInfos, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'rcMain @@ -122,6 +122,12 @@ Partial Class frmMain Me.btnPrint.RibbonStyle = CType(((DevExpress.XtraBars.Ribbon.RibbonItemStyles.Large Or DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithText) _ Or DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithoutText), DevExpress.XtraBars.Ribbon.RibbonItemStyles) ' + 'BarButtonItem1 + ' + Me.BarButtonItem1.Caption = "Playlist öffnen" + Me.BarButtonItem1.Id = 5 + Me.BarButtonItem1.Name = "BarButtonItem1" + ' 'rpGeneral ' Me.rpGeneral.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.rpgGeneral, Me.rpgManagement, Me.rpgPlaylists}) @@ -142,6 +148,12 @@ Partial Class frmMain Me.rpgManagement.Name = "rpgManagement" Me.rpgManagement.Text = "Verwaltung" ' + 'rpgPlaylists + ' + Me.rpgPlaylists.ItemLinks.Add(Me.BarButtonItem1) + Me.rpgPlaylists.Name = "rpgPlaylists" + Me.rpgPlaylists.Text = "Playlist" + ' 'grdSongs ' Me.grdSongs.ContextMenuStrip = Me.cmsSongs @@ -162,7 +174,7 @@ Partial Class frmMain Me.grdSongs.MainView = Me.grdvSongs Me.grdSongs.MenuManager = Me.rcMain Me.grdSongs.Name = "grdSongs" - Me.grdSongs.Size = New System.Drawing.Size(655, 342) + Me.grdSongs.Size = New System.Drawing.Size(655, 329) Me.grdSongs.TabIndex = 1 Me.grdSongs.UseEmbeddedNavigator = True Me.grdSongs.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.grdvSongs}) @@ -217,6 +229,62 @@ Partial Class frmMain Me.splMain.SplitterPosition = 450 Me.splMain.TabIndex = 3 ' + 'splLibraryPlaylists + ' + Me.splLibraryPlaylists.Dock = System.Windows.Forms.DockStyle.Fill + Me.splLibraryPlaylists.Horizontal = False + Me.splLibraryPlaylists.Location = New System.Drawing.Point(0, 0) + Me.splLibraryPlaylists.Name = "splLibraryPlaylists" + ' + 'splLibraryPlaylists.Panel1 + ' + Me.splLibraryPlaylists.Panel1.Controls.Add(Me.grdSongs) + Me.splLibraryPlaylists.Panel1.Text = "Panel1" + ' + 'splLibraryPlaylists.Panel2 + ' + Me.splLibraryPlaylists.Panel2.Controls.Add(Me.grdPlaylist) + Me.splLibraryPlaylists.Panel2.Text = "Panel2" + Me.splLibraryPlaylists.Size = New System.Drawing.Size(655, 603) + Me.splLibraryPlaylists.SplitterPosition = 329 + Me.splLibraryPlaylists.TabIndex = 3 + ' + 'grdPlaylist + ' + Me.grdPlaylist.ContextMenuStrip = Me.cmsSongs + Me.grdPlaylist.Dock = System.Windows.Forms.DockStyle.Fill + Me.grdPlaylist.EmbeddedNavigator.Buttons.Append.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.CancelEdit.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.Edit.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.EndEdit.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.First.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.Last.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.Next.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.NextPage.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.Prev.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.PrevPage.Visible = False + Me.grdPlaylist.EmbeddedNavigator.Buttons.Remove.Visible = False + Me.grdPlaylist.EmbeddedNavigator.TextStringFormat = "Song {0} von {1}" + Me.grdPlaylist.Location = New System.Drawing.Point(0, 0) + Me.grdPlaylist.MainView = Me.grdvPlaylist + Me.grdPlaylist.MenuManager = Me.rcMain + Me.grdPlaylist.Name = "grdPlaylist" + Me.grdPlaylist.Size = New System.Drawing.Size(655, 264) + Me.grdPlaylist.TabIndex = 2 + Me.grdPlaylist.UseEmbeddedNavigator = True + Me.grdPlaylist.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.grdvPlaylist}) + ' + 'grdvPlaylist + ' + Me.grdvPlaylist.GridControl = Me.grdPlaylist + Me.grdvPlaylist.Name = "grdvPlaylist" + Me.grdvPlaylist.OptionsBehavior.AutoExpandAllGroups = True + Me.grdvPlaylist.OptionsFind.AlwaysVisible = True + Me.grdvPlaylist.OptionsSelection.MultiSelect = True + Me.grdvPlaylist.OptionsView.ShowGroupPanel = False + Me.grdvPlaylist.OptionsView.ShowViewCaption = True + Me.grdvPlaylist.ViewCaption = "Playlist" + ' 'prgMain ' Me.prgMain.Anchor = System.Windows.Forms.AnchorStyles.None @@ -285,74 +353,6 @@ Partial Class frmMain Me.SFD.FileName = "Songliste.pdf" Me.SFD.Filter = "PDF-Dateien (*.pdf)|*.pdf|Alle Dateien (*.*)|*.*" ' - 'splLibraryPlaylists - ' - Me.splLibraryPlaylists.Dock = System.Windows.Forms.DockStyle.Fill - Me.splLibraryPlaylists.Horizontal = False - Me.splLibraryPlaylists.Location = New System.Drawing.Point(0, 0) - Me.splLibraryPlaylists.Name = "splLibraryPlaylists" - ' - 'splLibraryPlaylists.splLibraryPlaylists_Panel1 - ' - Me.splLibraryPlaylists.Panel1.Controls.Add(Me.grdSongs) - Me.splLibraryPlaylists.Panel1.Text = "Panel1" - ' - 'splLibraryPlaylists.splLibraryPlaylists_Panel2 - ' - Me.splLibraryPlaylists.Panel2.Controls.Add(Me.grdPlaylist) - Me.splLibraryPlaylists.Panel2.Text = "Panel2" - Me.splLibraryPlaylists.Size = New System.Drawing.Size(655, 603) - Me.splLibraryPlaylists.SplitterPosition = 342 - Me.splLibraryPlaylists.TabIndex = 3 - ' - 'grdPlaylist - ' - Me.grdPlaylist.ContextMenuStrip = Me.cmsSongs - Me.grdPlaylist.Dock = System.Windows.Forms.DockStyle.Fill - Me.grdPlaylist.EmbeddedNavigator.Buttons.Append.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.CancelEdit.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.Edit.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.EndEdit.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.First.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.Last.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.Next.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.NextPage.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.Prev.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.PrevPage.Visible = False - Me.grdPlaylist.EmbeddedNavigator.Buttons.Remove.Visible = False - Me.grdPlaylist.EmbeddedNavigator.TextStringFormat = "Song {0} von {1}" - Me.grdPlaylist.Location = New System.Drawing.Point(0, 0) - Me.grdPlaylist.MainView = Me.grdvPlaylist - Me.grdPlaylist.MenuManager = Me.rcMain - Me.grdPlaylist.Name = "grdPlaylist" - Me.grdPlaylist.Size = New System.Drawing.Size(655, 251) - Me.grdPlaylist.TabIndex = 2 - Me.grdPlaylist.UseEmbeddedNavigator = True - Me.grdPlaylist.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.grdvPlaylist}) - ' - 'grdvPlaylist - ' - Me.grdvPlaylist.GridControl = Me.grdPlaylist - Me.grdvPlaylist.Name = "grdvPlaylist" - Me.grdvPlaylist.OptionsBehavior.AutoExpandAllGroups = True - Me.grdvPlaylist.OptionsFind.AlwaysVisible = True - Me.grdvPlaylist.OptionsSelection.MultiSelect = True - Me.grdvPlaylist.OptionsView.ShowGroupPanel = False - Me.grdvPlaylist.OptionsView.ShowViewCaption = True - Me.grdvPlaylist.ViewCaption = "Playlist" - ' - 'rpgPlaylists - ' - Me.rpgPlaylists.ItemLinks.Add(Me.BarButtonItem1) - Me.rpgPlaylists.Name = "rpgPlaylists" - Me.rpgPlaylists.Text = "Playlist" - ' - 'BarButtonItem1 - ' - Me.BarButtonItem1.Caption = "Playlist öffnen" - Me.BarButtonItem1.Id = 5 - Me.BarButtonItem1.Name = "BarButtonItem1" - ' 'frmMain ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -374,14 +374,6 @@ Partial Class frmMain Me.splMain.Panel2.ResumeLayout(False) CType(Me.splMain, System.ComponentModel.ISupportInitialize).EndInit() Me.splMain.ResumeLayout(False) - CType(Me.splSongInfo.Panel1, System.ComponentModel.ISupportInitialize).EndInit() - Me.splSongInfo.Panel1.ResumeLayout(False) - CType(Me.splSongInfo.Panel2, System.ComponentModel.ISupportInitialize).EndInit() - Me.splSongInfo.Panel2.ResumeLayout(False) - CType(Me.splSongInfo, System.ComponentModel.ISupportInitialize).EndInit() - Me.splSongInfo.ResumeLayout(False) - CType(Me.grdSongInfos, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.grdvSongInfos, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.splLibraryPlaylists.Panel1, System.ComponentModel.ISupportInitialize).EndInit() Me.splLibraryPlaylists.Panel1.ResumeLayout(False) CType(Me.splLibraryPlaylists.Panel2, System.ComponentModel.ISupportInitialize).EndInit() @@ -390,6 +382,14 @@ Partial Class frmMain Me.splLibraryPlaylists.ResumeLayout(False) CType(Me.grdPlaylist, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.grdvPlaylist, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.splSongInfo.Panel1, System.ComponentModel.ISupportInitialize).EndInit() + Me.splSongInfo.Panel1.ResumeLayout(False) + CType(Me.splSongInfo.Panel2, System.ComponentModel.ISupportInitialize).EndInit() + Me.splSongInfo.Panel2.ResumeLayout(False) + CType(Me.splSongInfo, System.ComponentModel.ISupportInitialize).EndInit() + Me.splSongInfo.ResumeLayout(False) + CType(Me.grdSongInfos, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.grdvSongInfos, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() diff --git a/UltraStarSongPicker/frmMain.vb b/UltraStarSongPicker/frmMain.vb index 0f91bbf..8bb81e2 100644 --- a/UltraStarSongPicker/frmMain.vb +++ b/UltraStarSongPicker/frmMain.vb @@ -1,26 +1,41 @@ Imports System.ComponentModel -Imports System.Data.Common Imports System.Data.SQLite Imports System.IO -Imports AxWMPLib +Imports System.Reflection Imports DevExpress.XtraGrid Imports DevExpress.XtraGrid.Columns Imports DevExpress.XtraGrid.Views.Base Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraGrid.Views.Grid.ViewInfo -Imports DevExpress.XtraReports.UI Public Class frmMain - Public Property Songs As New List(Of Song) + Public Property Songs As New BindingList(Of Song) Dim ErrorMsgs As New List(Of String) Event ReadProgress(Caption As String, Description As String) + Dim dtPlaylist As DataTable + Dim dvPlaylist As DataView + Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load prepareGrid() + preparePlaylist() GetSongsFromDB() End Sub + Private Sub preparePlaylist() + dtPlaylist = New DataTable + For Each prop As PropertyInfo In GetType(Song).GetProperties() + dtPlaylist.Columns.Add(prop.Name) + Next + dvPlaylist = New DataView(dtPlaylist) + grdPlaylist.DataSource = dvPlaylist + With grdvPlaylist + .PopulateColumns() + + End With + End Sub + Private Sub prepareGrid() grdSongs.DataSource = Songs grdvSongs.PopulateColumns() @@ -49,7 +64,7 @@ Public Class frmMain .Columns(NameOf(Song.Previewstart)).Visible = False .Columns(NameOf(Song.FullPath)).Visible = False .Columns(NameOf(Song.FolderName)).Visible = False - .Columns(NameOf(Song.ExistsInFavDir)).Visible = False + .Columns(NameOf(Song.ExistsInUltrastar)).Visible = False .Columns(NameOf(Song.Songfilename)).Visible = False .Columns(NameOf(Song.VideoFilename)).Visible = False .Columns(NameOf(Song.CoverFilename)).Visible = False @@ -60,6 +75,7 @@ Public Class frmMain .Columns(NameOf(Song.Title)).Caption = "Titel" .Columns(NameOf(Song.ParentFolderName)).SortIndex = 2 .Columns(NameOf(Song.ParentFolderName)).Caption = "Ordnername" + .Columns(NameOf(Song.HasError)).Caption = "Fehlerhaft" .Columns(NameOf(Song.Language)).Caption = "Sprache" .Columns(NameOf(Song.Year)).Caption = "Jahr" .Columns(NameOf(Song.IsFavorite)).Caption = "Favorit" @@ -83,7 +99,7 @@ Public Class frmMain grdvSongs.FormatRules.Add(rule) rule = New GridFormatRule With { - .Column = grdvSongs.Columns(NameOf(Song.ExistsInFavDir)), + .Column = grdvSongs.Columns(NameOf(Song.ExistsInUltrastar)), .ApplyToRow = True, .Rule = New DevExpress.XtraEditors.FormatConditionRuleValue With { .Condition = DevExpress.XtraEditors.FormatCondition.Equal, @@ -109,7 +125,12 @@ Public Class frmMain Private Async Sub GetSongsFromDB() grdvSongs.BeginDataUpdate() - Songs = Await SongRepository.GetSongs() + Dim songlist As BindingList(Of Song) = Await SongRepository.GetSongs + Songs.Clear() + For Each s As Song In songlist + Songs.Add(s) + Next + CheckFavorites() grdvSongs.EndDataUpdate() @@ -121,7 +142,9 @@ Public Class frmMain 'Ordner auslesen prgMain.Visible = True - Await Task.Run(Sub() ImportSongsToDB(Pfade)) + Await Task.Run(Function() + Return ImportSongsToDB(Pfade) + End Function) prgMain.Visible = False @@ -134,11 +157,11 @@ Public Class frmMain GetSongsFromDB() End Sub - Private Sub ImportSongsToDB(Pfade As List(Of String)) + Private Function ImportSongsToDB(Pfade As List(Of String)) As Boolean Dim FavDirExists As Boolean = Directory.Exists(My.Settings.UltraStarDirectory) - Dim FavDir As String = My.Settings.UltraStarDirectory - If FavDir.EndsWith("\") = False Then FavDir &= "\" + Dim UltrastarDir As String = My.Settings.UltraStarDirectory + If UltrastarDir.EndsWith("\") = False Then UltrastarDir &= "\" Dim songinfofiles() As String Dim duetinfofiles() As String Dim song As Song @@ -165,7 +188,7 @@ Public Class frmMain End If song.ReadInfoFile() End If - If FavDirExists Then song.IsFavorite = Directory.Exists(FavDir & song.FolderName) + If FavDirExists Then song.IsFavorite = Directory.Exists(UltrastarDir & song.FolderName) templist.Add(song) End If songsread += CType(1, UInt64) @@ -177,7 +200,8 @@ Public Class frmMain Next SongRepository.DeleteAllSongs() SongRepository.SaveSongs(templist) - End Sub + Return True + End Function Private Sub CheckFavorites() Dim FavDir As String = My.Settings.UltraStarDirectory @@ -185,14 +209,14 @@ Public Class frmMain If Directory.Exists(FavDir) Then For Each s As Song In Songs If Directory.Exists(FavDir & s.FolderName) Then - s.ExistsInFavDir = True + s.ExistsInUltrastar = True Else - s.ExistsInFavDir = False + s.ExistsInUltrastar = False End If Next Else For Each s As Song In Songs - s.ExistsInFavDir = False + s.ExistsInUltrastar = False Next End If End Sub @@ -292,8 +316,8 @@ Public Class frmMain grdvSongs.CloseEditor() Dim FavDir = My.Settings.UltraStarDirectory - Dim ToAddToFavs As List(Of Song) = Songs.Where(Function(s) s.IsFavorite = True AndAlso s.ExistsInFavDir = False).ToList - Dim ToDeleteFromFavs As List(Of Song) = Songs.Where(Function(s) s.IsFavorite = False AndAlso s.ExistsInFavDir = True).ToList + Dim ToAddToFavs As List(Of Song) = Songs.Where(Function(s) s.IsFavorite = True AndAlso s.ExistsInUltrastar = False).ToList + Dim ToDeleteFromFavs As List(Of Song) = Songs.Where(Function(s) s.IsFavorite = False AndAlso s.ExistsInUltrastar = True).ToList If ToDeleteFromFavs.Count > 0 Then If MessageBox.Show($"Sind Sie sicher, dass Sie {ToDeleteFromFavs.Count} Lieder aus dem Favoritenverzeichnis entfernen möchten?{vbCrLf}Diese werden nicht in die ursprünglichen Verzeichnisse kopiert, daher sollten Sie ggf. sicherstellen ob diese Songs noch in den ursprünglichen Verzeichnissen vorhanden sind.{vbCrLf}{vbCrLf}Möchten Sie fortfahren?", "Löschen von Favoriten", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) <> DialogResult.Yes Then @@ -303,14 +327,14 @@ Public Class frmMain grdvSongs.BeginDataUpdate() prgMain.Visible = True - Await Task.Run(Sub() SyncFavDir(Songs)) + Await Task.Run(Sub() SyncPlaylistToUltrastarDir(Songs)) prgMain.Visible = False grdvSongs.EndDataUpdate() End Sub - Private Async Sub SyncFavDir(songlist As List(Of Song)) - Dim ToAddToFavs As List(Of Song) = songlist.Where(Function(s) s.IsFavorite = True AndAlso s.ExistsInFavDir = False).ToList - Dim ToDeleteFromFavs As List(Of Song) = songlist.Where(Function(s) s.IsFavorite = False AndAlso s.ExistsInFavDir = True).ToList + Private Async Sub SyncPlaylistToUltrastarDir(songlist As BindingList(Of Song)) + Dim ToAddToFavs As List(Of Song) = songlist.Where(Function(s) s.IsFavorite = True AndAlso s.ExistsInUltrastar = False).ToList + Dim ToDeleteFromFavs As List(Of Song) = songlist.Where(Function(s) s.IsFavorite = False AndAlso s.ExistsInUltrastar = True).ToList Dim FavDir = My.Settings.UltraStarDirectory Dim errors As New List(Of String) @@ -338,7 +362,7 @@ Public Class frmMain errors.Add($"Kopieren von '{song.FolderName}' ins Favoritenverzeichnis fehlgeschlagen:{vbCrLf} -> {ex.Message}") End Try If Directory.Exists(targetdir) Then - song.ExistsInFavDir = True + song.ExistsInUltrastar = True End If songcount += 1 Next @@ -357,7 +381,7 @@ Public Class frmMain Catch ex As Exception errors.Add($"Löschen von '{song.FolderName}' aus dem Favoritenverzeichnis fehlgeschlagen:{vbCrLf} -> {ex.Message}") End Try - If Directory.Exists(targetdir) = False Then song.ExistsInFavDir = False + If Directory.Exists(targetdir) = False Then song.ExistsInUltrastar = False songcount += 1 Next @@ -372,11 +396,11 @@ Public Class frmMain End Sub Private Sub btnPrint_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnPrint.ItemClick - If Songs.LongCount(Function(s) s.ExistsInFavDir = False AndAlso s.IsFavorite = True) > 0 Then + If Songs.LongCount(Function(s) s.ExistsInUltrastar = False AndAlso s.IsFavorite = True) > 0 Then End If Dim rep As New repFavoritesList - rep.DataSource = Songs.Where(Function(s) s.ExistsInFavDir = True) + rep.DataSource = Songs.Where(Function(s) s.ExistsInUltrastar = True) If SFD.ShowDialog = DialogResult.OK Then Try rep.ExportToPdf(SFD.FileName)