diff --git a/MPfm/MPfm.Library/Services/Interfaces/IUpdateLibraryService.cs b/MPfm/MPfm.Library/Services/Interfaces/IUpdateLibraryService.cs
index 670b748a..c5a10a48 100644
--- a/MPfm/MPfm.Library/Services/Interfaces/IUpdateLibraryService.cs
+++ b/MPfm/MPfm.Library/Services/Interfaces/IUpdateLibraryService.cs
@@ -1,39 +1,39 @@
-// Copyright © 2011-2013 Yanick Castonguay
-//
-// This file is part of MPfm.
-//
-// MPfm is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// MPfm is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MPfm. If not, see .
-
-using System;
-using System.Collections.Generic;
-using MPfm.Library.UpdateLibrary;
-using MPfm.Library.Services.Events;
-
-namespace MPfm.Library.Services.Interfaces
-{
- ///
- /// Update Library window presenter interface.
- ///
- public interface IUpdateLibraryService
- {
- event EventHandler RaiseRefreshStatusEvent;
- event EventHandler RaiseProcessEndedEvent;
-
- void Dispose();
- void UpdateLibrary(UpdateLibraryMode mode, List filePaths, string folderPath);
- void Cancel();
- void SaveLog(string filePath);
- }
-}
-
+// Copyright © 2011-2013 Yanick Castonguay
+//
+// This file is part of MPfm.
+//
+// MPfm is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// MPfm is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MPfm. If not, see .
+
+using System;
+using System.Collections.Generic;
+using MPfm.Library.Objects;
+using MPfm.Library.UpdateLibrary;
+using MPfm.Library.Services.Events;
+
+namespace MPfm.Library.Services.Interfaces
+{
+ ///
+ /// Update Library window presenter interface.
+ ///
+ public interface IUpdateLibraryService
+ {
+ event EventHandler RaiseRefreshStatusEvent;
+ event EventHandler RaiseProcessEndedEvent;
+
+ void UpdateLibrary(List filePaths, List folderPaths);
+ void Cancel();
+ void SaveLog(string filePath);
+ }
+}
+
diff --git a/MPfm/MPfm.Library/Services/UpdateLibraryService.cs b/MPfm/MPfm.Library/Services/UpdateLibraryService.cs
index 03e870d8..17e41058 100644
--- a/MPfm/MPfm.Library/Services/UpdateLibraryService.cs
+++ b/MPfm/MPfm.Library/Services/UpdateLibraryService.cs
@@ -20,58 +20,47 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using MPfm.Library.Objects;
+using MPfm.Library.Services.Events;
+using MPfm.Library.Services.Interfaces;
using MPfm.Library.UpdateLibrary;
using MPfm.Sound.AudioFiles;
-using System.Text.RegularExpressions;
-using MPfm.Library.Services.Interfaces;
-using MPfm.Library.Services.Events;
#if (MACOSX || LINUX)
using Mono.Unix;
using Mono.Unix.Native;
#endif
-namespace MPfm.MVP.Services
+namespace MPfm.Library.Services
{
///
/// Service used for updating the library with new audio files using a background worker.
///
public class UpdateLibraryService : IUpdateLibraryService
{
- private ILibraryService libraryService = null;
- private BackgroundWorker workerUpdateLibrary = null;
- private bool cancelUpdateLibrary = false;
+ private readonly ILibraryService _libraryService = null;
+ private BackgroundWorker _workerUpdateLibrary = null;
+ private bool _cancelUpdateLibrary = false;
public event EventHandler RaiseRefreshStatusEvent;
public event EventHandler RaiseProcessEndedEvent;
- #region Constructor and Dispose
-
///
/// Initializes a new instance of the class.
///
public UpdateLibraryService(ILibraryService libraryService)
{
if(libraryService == null)
- throw new ArgumentNullException("The libraryService parameter cannot be null!");
-
- this.libraryService = libraryService;
-
- workerUpdateLibrary = new BackgroundWorker();
- workerUpdateLibrary.WorkerReportsProgress = true;
- workerUpdateLibrary.WorkerSupportsCancellation = true;
- workerUpdateLibrary.DoWork += new DoWorkEventHandler(workerUpdateLibrary_DoWork);
- workerUpdateLibrary.RunWorkerCompleted += new RunWorkerCompletedEventHandler(workerUpdateLibrary_RunWorkerCompleted);
- }
+ throw new ArgumentNullException("The _libraryService parameter cannot be null!");
- public void Dispose()
- {
+ _libraryService = libraryService;
+ _workerUpdateLibrary = new BackgroundWorker();
+ _workerUpdateLibrary.WorkerReportsProgress = true;
+ _workerUpdateLibrary.WorkerSupportsCancellation = true;
+ _workerUpdateLibrary.DoWork += new DoWorkEventHandler(workerUpdateLibrary_DoWork);
+ _workerUpdateLibrary.RunWorkerCompleted += new RunWorkerCompletedEventHandler(workerUpdateLibrary_RunWorkerCompleted);
}
-
- #endregion
-
- #region Events
///
/// Raises the refresh status event. Wraps the event invocation by
@@ -96,17 +85,13 @@ protected virtual void OnRaiseProcessEndedEvent(ProcessEndedEventArgs e)
handler(this, e);
}
- #endregion
-
- #region IUpdateLibraryPresenter implementation
-
///
/// Cancels the update library process.
///
public void Cancel()
{
// Cancel process
- cancelUpdateLibrary = true;
+ _cancelUpdateLibrary = true;
}
///
@@ -138,31 +123,17 @@ public void SaveLog(string filePath)
// tw.Close();
// }
}
-
- #endregion
- ///
- /// Starts the update library process in a background thread.
- ///
- /// Update library mode
- /// Audio file paths to add to the database
- /// Folder path to add to the database
- public void UpdateLibrary(UpdateLibraryMode mode, List filePaths, string folderPath)
+ public void UpdateLibrary(List filePaths, List folderPaths)
{
- UpdateLibraryArgument arg = new UpdateLibraryArgument();
- arg.Mode = mode;
+ var arg = new UpdateLibraryArgument();
arg.FilePaths = filePaths;
- arg.FolderPath = folderPath;
+ arg.FolderPaths = folderPaths;
- cancelUpdateLibrary = false;
-
- if (mode == UpdateLibraryMode.SpecificFolder)
- libraryService.AddFolder(folderPath, true);
- else if(mode == UpdateLibraryMode.SpecificFiles)
- libraryService.AddFiles(filePaths);
+ _cancelUpdateLibrary = false;
// Start the background process
- workerUpdateLibrary.RunWorkerAsync(arg);
+ _workerUpdateLibrary.RunWorkerAsync(arg);
// TODO: Add time elapsed/time remaining
// // // Set start time when the process has finished finding the files and is ready to add files into library
@@ -219,46 +190,31 @@ protected void workerUpdateLibrary_DoWork(object sender, DoWorkEventArgs e)
{
List filePaths = new List();
UpdateLibraryArgument arg = (UpdateLibraryArgument)e.Argument;
+ filePaths.AddRange(arg.FilePaths);
try
{
- if (cancelUpdateLibrary) throw new UpdateLibraryException();
- if (arg.Mode == UpdateLibraryMode.WholeLibrary)
- {
- // Remove broken songs from the library
- OnRaiseRefreshStatusEvent(new UpdateLibraryEntity() {
- Title = "Checking for broken file paths",
- Subtitle = "Checking if songs have been deleted on your hard disk but not removed from the library..",
- PercentageDone = 0
- });
- libraryService.RemoveAudioFilesWithBrokenFilePaths();
+ // Remove broken songs from the library
+ OnRaiseRefreshStatusEvent(new UpdateLibraryEntity() {
+ Title = "Checking for broken file paths",
+ Subtitle = "Checking if songs have been deleted on your hard disk but not removed from the library..",
+ PercentageDone = 0
+ });
+ _libraryService.RemoveAudioFilesWithBrokenFilePaths();
- if (cancelUpdateLibrary) throw new UpdateLibraryException();
+ if (_cancelUpdateLibrary) throw new UpdateLibraryException();
- filePaths = SearchMediaFilesInFolders();
- }
- else if (arg.Mode == UpdateLibraryMode.SpecificFiles)
- {
- // Set the media files passed in the argument
- filePaths = arg.FilePaths;
- }
- else if (arg.Mode == UpdateLibraryMode.SpecificFolder)
- {
- // Search the files in the specified folder
- Console.WriteLine("UpdateLibraryService - Looking for audio files in {0}...", arg.FolderPath);
- filePaths = SearchMediaFilesInFolders(arg.FolderPath, true);
- Console.WriteLine("UpdateLibraryService - Found {0} audio files in {0}", filePaths.Count, arg.FolderPath);
- }
+ filePaths = SearchMediaFilesInFolders(arg.FolderPaths);
- if (cancelUpdateLibrary) throw new UpdateLibraryException();
+ if (_cancelUpdateLibrary) throw new UpdateLibraryException();
// Get the list of audio files from the database
- IEnumerable filePathsDatabase = libraryService.SelectFilePaths();
+ IEnumerable filePathsDatabase = _libraryService.SelectFilePaths();
IEnumerable filePathsToUpdate = filePaths.Except(filePathsDatabase);
for(int a = 0; a < filePathsToUpdate.Count(); a++)
{
- if (cancelUpdateLibrary) throw new UpdateLibraryException();
+ if (_cancelUpdateLibrary) throw new UpdateLibraryException();
// Get current file path and calculate stats
string filePath = filePathsToUpdate.ElementAt(a);
@@ -273,12 +229,12 @@ protected void workerUpdateLibrary_DoWork(object sender, DoWorkEventArgs e)
filePath.ToUpper().Contains(".XSPF"))
{
PlaylistFile playlistFile = new PlaylistFile(filePath);
- libraryService.InsertPlaylistFile(playlistFile);
+ _libraryService.InsertPlaylistFile(playlistFile);
}
else
{
AudioFile audioFile = new AudioFile(filePath, Guid.NewGuid(), true);
- libraryService.InsertAudioFile(audioFile);
+ _libraryService.InsertAudioFile(audioFile);
}
// Display update
@@ -308,7 +264,7 @@ protected void workerUpdateLibrary_DoWork(object sender, DoWorkEventArgs e)
}
// Cancel thread if necessary
- if (cancelUpdateLibrary) throw new UpdateLibraryException();
+ if (_cancelUpdateLibrary) throw new UpdateLibraryException();
// Compact database
OnRaiseRefreshStatusEvent(new UpdateLibraryEntity() {
@@ -316,7 +272,7 @@ protected void workerUpdateLibrary_DoWork(object sender, DoWorkEventArgs e)
Subtitle = "Compacting database...",
PercentageDone = 1
});
- libraryService.CompactDatabase();
+ _libraryService.CompactDatabase();
}
catch (UpdateLibraryException ex)
{
@@ -345,16 +301,10 @@ private void workerUpdateLibrary_RunWorkerCompleted(object sender, RunWorkerComp
OnRaiseProcessEndedEvent(new ProcessEndedEventArgs(e.Cancelled));
}
- ///
- /// Searches for songs in all configured folders.
- ///
- /// List of songs (file paths)
- public List SearchMediaFilesInFolders()
+ public List SearchMediaFilesInFolders(List folders)
{
List files = new List();
- IEnumerable folders = libraryService.SelectFolders();
-
- foreach (Folder folder in folders)
+ foreach (var folder in folders)
{
List newFiles = SearchMediaFilesInFolders(folder.FolderPath, (bool)folder.IsRecursive);
files.AddRange(newFiles);
diff --git a/MPfm/MPfm.Library/UpdateLibrary/UpdateLibraryArgument.cs b/MPfm/MPfm.Library/UpdateLibrary/UpdateLibraryArgument.cs
index cd3899b7..48531823 100644
--- a/MPfm/MPfm.Library/UpdateLibrary/UpdateLibraryArgument.cs
+++ b/MPfm/MPfm.Library/UpdateLibrary/UpdateLibraryArgument.cs
@@ -1,51 +1,37 @@
-// Copyright © 2011-2013 Yanick Castonguay
-//
-// This file is part of MPfm.
-//
-// MPfm is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// MPfm is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MPfm. If not, see .
-
-using System.Collections.Generic;
-
-namespace MPfm.Library.UpdateLibrary
-{
- ///
- /// Arguments for the background worker that updates the library.
- ///
- public class UpdateLibraryArgument
- {
- ///
- /// Update library mode.
- ///
- public UpdateLibraryMode Mode { get; set; }
- ///
- /// List of files to update (necessary for the SpecificFiles update library mode).
- ///
- public List FilePaths { get; set; }
- ///
- /// Folder path to update (necessary for the SpecificFolder update library mode).
- ///
- public string FolderPath { get; set; }
-
- ///
- /// Constructor for UpdateLibraryArguments.
- ///
- public UpdateLibraryArgument()
- {
- // Set default arguments
- Mode = UpdateLibraryMode.WholeLibrary;
- FilePaths = new List();
- FolderPath = string.Empty;
- }
- }
-}
+// Copyright © 2011-2013 Yanick Castonguay
+//
+// This file is part of MPfm.
+//
+// MPfm is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// MPfm is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MPfm. If not, see .
+
+using System.Collections.Generic;
+using MPfm.Library.Objects;
+
+namespace MPfm.Library.UpdateLibrary
+{
+ ///
+ /// Arguments for the background worker that updates the library.
+ ///
+ public class UpdateLibraryArgument
+ {
+ public List FilePaths { get; set; }
+ public List FolderPaths { get; set; }
+
+ public UpdateLibraryArgument()
+ {
+ FilePaths = new List();
+ FolderPaths = new List();
+ }
+ }
+}
diff --git a/MPfm/MPfm.MVP/Config/Models/LibraryAppConfig.cs b/MPfm/MPfm.MVP/Config/Models/LibraryAppConfig.cs
new file mode 100644
index 00000000..49f25485
--- /dev/null
+++ b/MPfm/MPfm.MVP/Config/Models/LibraryAppConfig.cs
@@ -0,0 +1,35 @@
+// Copyright © 2011-2013 Yanick Castonguay
+//
+// This file is part of MPfm.
+//
+// MPfm is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// MPfm is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MPfm. If not, see .
+
+using System.Collections.Generic;
+using MPfm.Library.Objects;
+
+namespace MPfm.MVP.Config.Models
+{
+ ///
+ /// Class containing all library settings.
+ ///
+ public class LibraryAppConfig : IAppConfig
+ {
+ public List Folders { get; set; }
+
+ public LibraryAppConfig()
+ {
+ Folders = new List();
+ }
+ }
+}
diff --git a/MPfm/MPfm.MVP/Config/Models/RootAppConfig.cs b/MPfm/MPfm.MVP/Config/Models/RootAppConfig.cs
index a974360b..ba81049e 100644
--- a/MPfm/MPfm.MVP/Config/Models/RootAppConfig.cs
+++ b/MPfm/MPfm.MVP/Config/Models/RootAppConfig.cs
@@ -36,6 +36,7 @@ public class RootAppConfig : IAppConfig
public AudioAppConfig Audio { get; set; }
public CloudAppConfig Cloud { get; set; }
+ public LibraryAppConfig Library { get; set; }
public ControlsAppConfig Controls { get; set; }
public WindowsAppConfig Windows { get; set; }
@@ -50,6 +51,7 @@ public RootAppConfig()
Audio = new AudioAppConfig();
Cloud = new CloudAppConfig();
Controls = new ControlsAppConfig();
+ Library = new LibraryAppConfig();
Windows = new WindowsAppConfig();
}
}
diff --git a/MPfm/MPfm.MVP/MPfm.MVP.csproj b/MPfm/MPfm.MVP/MPfm.MVP.csproj
index d233e57d..d51b9168 100644
--- a/MPfm/MPfm.MVP/MPfm.MVP.csproj
+++ b/MPfm/MPfm.MVP/MPfm.MVP.csproj
@@ -128,6 +128,7 @@
+
diff --git a/MPfm/MPfm.MVP/Navigation/NavigationManager.cs b/MPfm/MPfm.MVP/Navigation/NavigationManager.cs
index aa379e72..1bb9f450 100644
--- a/MPfm/MPfm.MVP/Navigation/NavigationManager.cs
+++ b/MPfm/MPfm.MVP/Navigation/NavigationManager.cs
@@ -372,7 +372,7 @@ public virtual IPlaylistView CreatePlaylistView()
return _playlistView;
}
- public virtual IUpdateLibraryView CreateUpdateLibraryView(UpdateLibraryMode mode, List filePaths, string folderPath)
+ public virtual IUpdateLibraryView CreateUpdateLibraryView(List filePaths, List folderPaths)
{
if (_updateLibraryView != null)
{
@@ -384,7 +384,7 @@ public virtual IUpdateLibraryView CreateUpdateLibraryView(UpdateLibraryMode mode
{
_updateLibraryPresenter = Bootstrapper.GetContainer().Resolve();
_updateLibraryPresenter.BindView((IUpdateLibraryView)view);
- _updateLibraryPresenter.UpdateLibrary(mode, filePaths, folderPath);
+ _updateLibraryPresenter.UpdateLibrary(filePaths, folderPaths);
};
_updateLibraryView = Bootstrapper.GetContainer().Resolve(new NamedParameterOverloads() { { "onViewReady", onViewReady } });
diff --git a/MPfm/MPfm.MVP/Presenters/Interfaces/IUpdateLibraryPresenter.cs b/MPfm/MPfm.MVP/Presenters/Interfaces/IUpdateLibraryPresenter.cs
index 406bdc8f..0de36c09 100644
--- a/MPfm/MPfm.MVP/Presenters/Interfaces/IUpdateLibraryPresenter.cs
+++ b/MPfm/MPfm.MVP/Presenters/Interfaces/IUpdateLibraryPresenter.cs
@@ -1,34 +1,35 @@
-// Copyright © 2011-2013 Yanick Castonguay
-//
-// This file is part of MPfm.
-//
-// MPfm is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// MPfm is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with MPfm. If not, see .
-
-using System.Collections.Generic;
-using MPfm.Library.UpdateLibrary;
-using MPfm.MVP.Views;
-
-namespace MPfm.MVP.Presenters.Interfaces
-{
- ///
- /// Update Library window presenter interface.
- ///
- public interface IUpdateLibraryPresenter : IBasePresenter
- {
- void UpdateLibrary(UpdateLibraryMode mode, List filePaths, string folderPath);
- void Cancel();
- void SaveLog(string filePath);
- }
-}
-
+// Copyright © 2011-2013 Yanick Castonguay
+//
+// This file is part of MPfm.
+//
+// MPfm is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// MPfm is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with MPfm. If not, see .
+
+using System.Collections.Generic;
+using MPfm.Library.Objects;
+using MPfm.Library.UpdateLibrary;
+using MPfm.MVP.Views;
+
+namespace MPfm.MVP.Presenters.Interfaces
+{
+ ///
+ /// Update Library window presenter interface.
+ ///
+ public interface IUpdateLibraryPresenter : IBasePresenter
+ {
+ void UpdateLibrary(List filePaths, List folderPaths);
+ void Cancel();
+ void SaveLog(string filePath);
+ }
+}
+
diff --git a/MPfm/MPfm.MVP/Presenters/LibraryPreferencesPresenter.cs b/MPfm/MPfm.MVP/Presenters/LibraryPreferencesPresenter.cs
index d369f7bd..3dd1b6e2 100644
--- a/MPfm/MPfm.MVP/Presenters/LibraryPreferencesPresenter.cs
+++ b/MPfm/MPfm.MVP/Presenters/LibraryPreferencesPresenter.cs
@@ -16,10 +16,13 @@
// along with MPfm. If not, see .
using System;
+using System.Collections.Generic;
using MPfm.Core;
using MPfm.Library.Services.Interfaces;
using MPfm.Library.UpdateLibrary;
using MPfm.MVP.Bootstrap;
+using MPfm.MVP.Config;
+using MPfm.MVP.Config.Models;
using MPfm.MVP.Navigation;
using MPfm.MVP.Presenters.Interfaces;
using MPfm.MVP.Views;
@@ -53,6 +56,7 @@ public class LibraryPreferencesPresenter : BasePresenter(), AppConfigManager.Instance.Root.Library.Folders);
#endif
}
catch(Exception ex)
diff --git a/MPfm/MPfm.MVP/Presenters/MainPresenter.cs b/MPfm/MPfm.MVP/Presenters/MainPresenter.cs
index fd26a68a..13094b0c 100644
--- a/MPfm/MPfm.MVP/Presenters/MainPresenter.cs
+++ b/MPfm/MPfm.MVP/Presenters/MainPresenter.cs
@@ -16,7 +16,10 @@
// along with MPfm. If not, see .
using System.Collections.Generic;
+using System.Linq;
+using MPfm.Library.Objects;
using MPfm.Library.UpdateLibrary;
+using MPfm.MVP.Config;
using MPfm.MVP.Navigation;
using MPfm.MVP.Presenters.Interfaces;
using MPfm.MVP.Views;
@@ -44,9 +47,28 @@ public override void BindView(IMainView view)
view.OnOpenSyncCloudWindow = () => _navigationManager.CreateSyncCloudView();
view.OnOpenSyncWebBrowserWindow = () => _navigationManager.CreateSyncWebBrowserView();
view.OnOpenResumePlayback = () => _navigationManager.CreateResumePlaybackView();
- view.OnAddFilesToLibrary = (filePaths) => _navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.SpecificFiles, filePaths, null);
- view.OnAddFolderToLibrary = (folderPath) => _navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.SpecificFolder, null, folderPath);
- view.OnUpdateLibrary = () => _navigationManager.CreateUpdateLibraryView(UpdateLibraryMode.WholeLibrary, null, null);
+ view.OnAddFilesToLibrary = (filePaths) => _navigationManager.CreateUpdateLibraryView(filePaths, new List());
+ view.OnAddFolderToLibrary = (folderPath) =>
+ {
+ var folders = new List();
+ folders.Add(new Folder()
+ {
+ FolderPath = folderPath,
+ IsRecursive = true
+ });
+
+ // Add to list of configured folders
+ var foundFolder = AppConfigManager.Instance.Root.Library.Folders.FirstOrDefault(x => x.FolderPath == folderPath);
+ if (foundFolder == null)
+ {
+ AppConfigManager.Instance.Root.Library.Folders.Add(folders[0]);
+ AppConfigManager.Instance.Save();
+ }
+
+ // Start update library
+ _navigationManager.CreateUpdateLibraryView(new List(), folders);
+ };
+ view.OnUpdateLibrary = () => _navigationManager.CreateUpdateLibraryView(new List(), AppConfigManager.Instance.Root.Library.Folders);
base.BindView(view);
}
diff --git a/MPfm/MPfm.MVP/Presenters/UpdateLibraryPresenter.cs b/MPfm/MPfm.MVP/Presenters/UpdateLibraryPresenter.cs
index 3f01a661..39be2c1b 100644
--- a/MPfm/MPfm.MVP/Presenters/UpdateLibraryPresenter.cs
+++ b/MPfm/MPfm.MVP/Presenters/UpdateLibraryPresenter.cs
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
+using MPfm.Library.Objects;
using MPfm.Library.UpdateLibrary;
using MPfm.MVP.Presenters.Interfaces;
using MPfm.MVP.Services.Interfaces;
@@ -77,16 +78,9 @@ public override void BindView(IUpdateLibraryView view)
view.OnSaveLog = SaveLog;
}
- ///
- /// Starts the update library process in a background thread.
- /// The Update Library view will be updated during progress.
- ///
- /// Update library mode
- /// Audio file paths to add to the database
- /// Folder path to add to the database
- public void UpdateLibrary(UpdateLibraryMode mode, List filePaths, string folderPath)
+ public void UpdateLibrary(List filePaths, List folderPaths)
{
- _updateLibraryService.UpdateLibrary(mode, filePaths, folderPath);
+ _updateLibraryService.UpdateLibrary(filePaths, folderPaths);
}
///
diff --git a/MPfm/MPfm.MVP/Views/ILibraryPreferencesView.cs b/MPfm/MPfm.MVP/Views/ILibraryPreferencesView.cs
index d7b3f2de..e824977b 100644
--- a/MPfm/MPfm.MVP/Views/ILibraryPreferencesView.cs
+++ b/MPfm/MPfm.MVP/Views/ILibraryPreferencesView.cs
@@ -14,7 +14,10 @@
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see .
+
using System;
+using System.Collections.Generic;
+using MPfm.MVP.Config.Models;
namespace MPfm.MVP.Views
{
@@ -23,6 +26,7 @@ namespace MPfm.MVP.Views
///
public interface ILibraryPreferencesView : IBaseView
{
+ Action OnSetLibraryPreferences { get; set; }
Action OnSelectFolders { get; set; }
Action OnResetLibrary { get; set; }
Action OnUpdateLibrary { get; set; }
@@ -30,5 +34,6 @@ public interface ILibraryPreferencesView : IBaseView
Action OnSetSyncListenerPort { get; set; }
void LibraryPreferencesError(Exception ex);
+ void RefreshLibraryPreferences(LibraryAppConfig config);
}
}
diff --git a/MPfm/MPfm.MVP/Views/IUpdateLibraryView.cs b/MPfm/MPfm.MVP/Views/IUpdateLibraryView.cs
index 230ad832..78b5495b 100644
--- a/MPfm/MPfm.MVP/Views/IUpdateLibraryView.cs
+++ b/MPfm/MPfm.MVP/Views/IUpdateLibraryView.cs
@@ -28,7 +28,7 @@ namespace MPfm.MVP.Views
///
public interface IUpdateLibraryView : IBaseView
{
- Action, string> OnStartUpdateLibrary { get; set; }
+ Action, List> OnStartUpdateLibrary { get; set; }
Action OnCancelUpdateLibrary { get; set; }
Action OnSaveLog { get; set; }
diff --git a/MPfm/MPfm.WPF/Classes/Windows/PreferencesWindow.xaml b/MPfm/MPfm.WPF/Classes/Windows/PreferencesWindow.xaml
index a47151a7..9312d094 100644
--- a/MPfm/MPfm.WPF/Classes/Windows/PreferencesWindow.xaml
+++ b/MPfm/MPfm.WPF/Classes/Windows/PreferencesWindow.xaml
@@ -4,6 +4,7 @@
xmlns:base="clr-namespace:MPfm.WPF.Classes.Windows.Base"
xmlns:controls="clr-namespace:MPfm.WPF.Classes.Controls"
xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
+ xmlns:models="clr-namespace:MPfm.Library.Objects;assembly=MPfm.Library"
WindowStartupLocation="CenterScreen" Background="#FF242F35"
Title="Preferences" Height="500" Width="680" Icon="/MPfm.WPF;component/Resources/Icon.ico">
@@ -53,7 +54,7 @@
-
+
@@ -61,36 +62,51 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+