Skip to content

Commit

Permalink
increase portibility, fix #208
Browse files Browse the repository at this point in the history
  • Loading branch information
theweavr committed Nov 14, 2017
1 parent a5337f4 commit 4ff0a3d
Show file tree
Hide file tree
Showing 95 changed files with 381 additions and 343 deletions.
File renamed without changes.
16 changes: 16 additions & 0 deletions BreadPlayer.Common/BreadPlayer.Common.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.6.0-dev-00923" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BreadPlayer.Interfaces\BreadPlayer.Interfaces.csproj" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions BreadPlayer.Common/InitializeSwitch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using BreadPlayer.Interfaces;

public class InitializeSwitch
{
public InitializeSwitch(INotificationManager notificationManager, IEqualizerSettingsHelper equalizerSettingsHelper, IDispatcher dispatcher, bool isMobile)
{
NotificationManager = notificationManager;
EqualizerSettingsHelper = equalizerSettingsHelper;
Dispatcher = dispatcher;
IsMobile = isMobile;
}
public static bool IsMobile { get; set; }
public static INotificationManager NotificationManager { get; private set; }
public static IEqualizerSettingsHelper EqualizerSettingsHelper { get; private set; }
public static IDispatcher Dispatcher { get; private set; }
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected void RaisePropertyChanged([CallerMemberName] string propertyName = nul
/// <param name="args">The arguments. </param>
protected async virtual void RaisePropertyChanged(PropertyChangedEventArgs args)
{
if (InitializeFramework.Dispatcher != null)
if (InitializeSwitch.Dispatcher != null)
{
await InitializeFramework.Dispatcher?.RunAsync(() => { PropertyChanged?.Invoke(this, args); });
await InitializeSwitch.Dispatcher?.RunAsync(() => { PropertyChanged?.Invoke(this, args); });
}
else
{
Expand Down
14 changes: 3 additions & 11 deletions BreadPlayer.Controls/BreadPlayer.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Compile Include="AlternativeRowListView\AlternateRowListView.cs" />
<Compile Include="GroupHeaderDataTemplateSelector.cs" />
<Compile Include="ImageEx\BitmapCache.cs" />
<Compile Include="ImageEx\BitmapTools.cs" />
<Compile Include="ImageEx\ImageEx.cs" />
<Compile Include="ImageEx\ImageEx.Members.cs" />
<Compile Include="ImageEx\ImageEx.Source.cs" />
<Compile Include="ImageEx\SizeExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\BreadPlayer.Controls.rd.xml" />
</ItemGroup>
Expand All @@ -132,9 +124,9 @@
<Project>{e5851a02-a8ce-4f4d-8b5f-0986013ae830}</Project>
<Name>BreadPlayer.Extensions</Name>
</ProjectReference>
<ProjectReference Include="..\BreadPlayer.Framework\BreadPlayer.Framework.csproj">
<Project>{f22742c9-7088-4325-9f87-0a1aa34dda74}</Project>
<Name>BreadPlayer.Framework</Name>
<ProjectReference Include="..\BreadPlayer.Interfaces\BreadPlayer.Interfaces.csproj">
<Project>{412718BB-903F-482F-8577-99B8EFCD96D2}</Project>
<Name>BreadPlayer.Interfaces</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
Expand Down
27 changes: 14 additions & 13 deletions BreadPlayer.Core/BreadPlayer.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,34 +102,24 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Compile Include="BreadLogger\BLogger.cs" />
<Compile Include="BreadLogger\ISentryMessageSender.cs" />
<Compile Include="Common\Collections.cs" />
<Compile Include="Common\ConfigSaver.cs" />
<Compile Include="Common\DelegateCommand.cs" />
<Compile Include="Common\Enums.cs" />
<Compile Include="Common\ICommand.cs" />
<Compile Include="Common\INotificationManager.cs" />
<Compile Include="Common\IEqualizerSettingsHelper.cs" />
<Compile Include="Common\IPinnable.cs" />
<Compile Include="Common\ISelectable.cs" />
<Compile Include="Common\PasswordStorage.cs" />
<Compile Include="Engines\BASSEngine\BassEqualizer.cs" />
<Compile Include="Engines\BASSEngine\BassEqualizerBand.cs" />
<Compile Include="Events\MediaAboutToEndEventArgs.cs" />
<Compile Include="Events\MediaEndedEventArgs.cs" />
<Compile Include="Events\MediaStateChangedEventArgs.cs" />
<Compile Include="Extensions\ObservableCollection.cs" />
<Compile Include="Common\IDBRecord.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="InitializeCore.cs" />
<Compile Include="Models\Album.cs" />
<Compile Include="Models\Artist.cs" />
<Compile Include="Models\DiskItem.cs" />
<Compile Include="Models\DiskItemLocationType.cs" />
<Compile Include="Models\EqualizerBand.cs" />
<Compile Include="Models\GroupKeys.cs" />
<Compile Include="Models\IGroupKey.cs" />
<Compile Include="Models\Mediafile.cs" />
<Compile Include="Models\MediaLocationType.cs" />
<Compile Include="Models\Playlist.cs" />
Expand All @@ -145,9 +135,17 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BreadPlayer.Framework\BreadPlayer.Framework.csproj">
<Project>{f22742c9-7088-4325-9f87-0a1aa34dda74}</Project>
<Name>BreadPlayer.Framework</Name>
<ProjectReference Include="..\BreadPlayer.Common\BreadPlayer.Common.csproj">
<Project>{47af841a-4b78-490d-8915-7f58cdbdbeb3}</Project>
<Name>BreadPlayer.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BreadPlayer.Extensions\BreadPlayer.Extensions.csproj">
<Project>{e5851a02-a8ce-4f4d-8b5f-0986013ae830}</Project>
<Name>BreadPlayer.Extensions</Name>
</ProjectReference>
<ProjectReference Include="..\BreadPlayer.Interfaces\BreadPlayer.Interfaces.csproj">
<Project>{412718bb-903f-482f-8577-99b8efcd96d2}</Project>
<Name>BreadPlayer.Interfaces</Name>
</ProjectReference>
<ProjectReference Include="..\BreadPlayer.Parsers\BreadPlayer.Parsers.csproj">
<Project>{ec3f27a8-ab79-420f-aef2-8d3316abab3c}</Project>
Expand All @@ -157,6 +155,9 @@
<ItemGroup>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="BreadLogger\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
5 changes: 3 additions & 2 deletions BreadPlayer.Core/Common/ConfigSaver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BreadPlayer.Core.Models;
using BreadPlayer.Interfaces;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -64,9 +65,9 @@ public EqualizerSettings MakeSetting(string name, Dictionary<string, float> band
return equalizerSettings;
}

public IEnumerable<EqualizerSettings> GetSettings()
public IEnumerable<IEqualizerSettings> GetSettings()
{
var savedPresets = InitializeCore.EqualizerSettingsHelper.LoadEqualizerPresets();
var savedPresets = InitializeSwitch.EqualizerSettingsHelper.LoadEqualizerPresets();
if(savedPresets?.Any() == true)
{
return savedPresets;
Expand Down
1 change: 1 addition & 0 deletions BreadPlayer.Core/Common/DelegateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using BreadPlayer.Interfaces;
using System;
using System.Diagnostics;

Expand Down
15 changes: 0 additions & 15 deletions BreadPlayer.Core/Common/IEqualizerSettingsHelper.cs

This file was deleted.

14 changes: 7 additions & 7 deletions BreadPlayer.Core/Engines/BASSEngine/BASSPlayerEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ await Task.Run(() =>
public async Task ChangeDevice(string deviceName = null)
{
if (deviceName != null)
await InitializeCore.NotificationManager.ShowMessageAsync($"Transitioning to {deviceName}.", 5);
await InitializeSwitch.NotificationManager.ShowMessageAsync($"Transitioning to {deviceName}.", 5);

await Task.Run(() =>
{
Expand All @@ -122,7 +122,7 @@ await Task.Run(() =>
PlayerState = PlayerState.Paused;
}

if (InitializeCore.IsMobile)
if (InitializeSwitch.IsMobile)
NativeMethods.BASS_SetConfig(NativeMethods.BassConfigDevBuffer, (int)DeviceBufferSize);

Bass.Init();
Expand All @@ -138,7 +138,7 @@ await Task.Run(() =>
});

if (deviceName != null)
await InitializeCore.NotificationManager.ShowMessageAsync($"Transition to {deviceName} complete.", 5);
await InitializeSwitch.NotificationManager.ShowMessageAsync($"Transition to {deviceName} complete.", 5);
}
public async Task<bool> LoadURLAsync(Mediafile mediafile, string uri)
{
Expand Down Expand Up @@ -241,7 +241,7 @@ public async Task<bool> LoadLocalFileAsync(Mediafile mediaFile)
else
{
string error = "The file " + mediaFile?.OrginalFilename + " is either corrupt, incomplete or unavailable. \r\n\r\n Exception details: No data available.";
await InitializeCore.NotificationManager.ShowMessageAsync(error);
await InitializeSwitch.NotificationManager.ShowMessageAsync(error);
return false;
}
}
Expand All @@ -253,7 +253,7 @@ private async Task<bool> LoadMusicAsync(Action LoadMusicAction)
{
try
{
await InitializeCore.Dispatcher.RunAsync(() =>
await InitializeSwitch.Dispatcher.RunAsync(() =>
{
MediaChanging?.Invoke(this, new EventArgs());
});
Expand All @@ -273,7 +273,7 @@ await Task.Run(() =>
Bass.ChannelSetSync(_handle, SyncFlags.Position, Bass.ChannelSeconds2Bytes(_handle, Length - 15), _posSync);

});
if (InitializeCore.IsMobile)
if (InitializeSwitch.IsMobile)
await ChangeDevice();
if (Equalizer == null)
{
Expand All @@ -290,7 +290,7 @@ await Task.Run(() =>
catch (Exception ex)
{
BLogger.E("An error occured while loading music. Action {action}", ex, LoadMusicAction.ToString());
await InitializeCore.NotificationManager.ShowMessageAsync(ex.Message);
await InitializeSwitch.NotificationManager.ShowMessageAsync(ex.Message);
return false;
}
}
Expand Down
5 changes: 3 additions & 2 deletions BreadPlayer.Core/Engines/BASSEngine/BassEqualizer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BreadPlayer.Core.Common;
using BreadPlayer.Core.Engines.Interfaces;
using BreadPlayer.Core.Models;
using BreadPlayer.Interfaces;
using ManagedBass;
using ManagedBass.Fx;
using System;
Expand All @@ -22,8 +23,8 @@ public BassEqualizer(int coreHandle)
IsPreampAvailable = true;

Bands = new ObservableCollection<IEqualizerBand>();
Presets = new ObservableCollection<EqualizerSettings>(new ConfigSaver().GetSettings());
EqualizerSettings = InitializeCore.EqualizerSettingsHelper.LoadEqualizerSettings("CustomEq").settings;
Presets = new ObservableCollection<IEqualizerSettings>(new ConfigSaver().GetSettings());
EqualizerSettings = InitializeSwitch.EqualizerSettingsHelper.LoadEqualizerSettings("CustomEq").settings;
Name = EqualizerSettings.Name;
SelectedPreset = Presets.IndexOf(Presets.FirstOrDefault(t => t.Name == EqualizerSettings.Name));

Expand Down
9 changes: 5 additions & 4 deletions BreadPlayer.Core/Engines/Interfaces/IEqualizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BreadPlayer.Core.Models;
using BreadPlayer.Interfaces;
using System.Collections.ObjectModel;
using System.Linq;

Expand All @@ -21,8 +22,8 @@ public abstract class Equalizer : ObservableObject
new[] {8000f, 1f, 0f},
new[] {16000f, 1f, 0f }
};
public EqualizerSettings EqualizerSettings { get; set; }
public ObservableCollection<EqualizerSettings> Presets { get; set; }
public IEqualizerSettings EqualizerSettings { get; set; }
public ObservableCollection<IEqualizerSettings> Presets { get; set; }
private int _selectedPreset = -1;

public int SelectedPreset
Expand Down Expand Up @@ -91,8 +92,8 @@ public void SaveEqualizerSettings()
}
equalizerSettings.GainValues = Bands.ToDictionary(b => b.BandCaption, b => b.Gain);
equalizerSettings.IsEnabled = IsEnabled;
InitializeCore.EqualizerSettingsHelper.SaveEqualizerSettings(equalizerSettings, 1);
InitializeCore.EqualizerSettingsHelper.SaveEqualizerPresets(Presets);
InitializeSwitch.EqualizerSettingsHelper.SaveEqualizerSettings(equalizerSettings, 1);
InitializeSwitch.EqualizerSettingsHelper.SaveEqualizerPresets(Presets);
}

public void SetToDefault()
Expand Down
37 changes: 0 additions & 37 deletions BreadPlayer.Core/InitializeCore.cs

This file was deleted.

3 changes: 1 addition & 2 deletions BreadPlayer.Core/Models/Album.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BreadPlayer.Core.Common;
using BreadPlayer.Interfaces;
using LiteDB;
using Newtonsoft.Json;
using System;

namespace BreadPlayer.Core.Models
Expand Down
3 changes: 1 addition & 2 deletions BreadPlayer.Core/Models/Artist.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BreadPlayer.Core.Common;
using BreadPlayer.Interfaces;
using LiteDB;
using Newtonsoft.Json;

namespace BreadPlayer.Core.Models
{
Expand Down
1 change: 1 addition & 0 deletions BreadPlayer.Core/Models/ChildSong.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BreadPlayer.Core.Common;
using BreadPlayer.Interfaces;

namespace BreadPlayer.Core.Models
{
Expand Down
5 changes: 3 additions & 2 deletions BreadPlayer.Core/Models/EqualizerSettings.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Collections.Generic;
using BreadPlayer.Interfaces;
using System.Collections.Generic;

namespace BreadPlayer.Core.Models
{
public class EqualizerSettings
public class EqualizerSettings : IEqualizerSettings
{
public string Name { get; set; }
public Dictionary<string, float> GainValues { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion BreadPlayer.Core/Models/GroupKeys.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace BreadPlayer.Core.Models
using BreadPlayer.Interfaces;

namespace BreadPlayer.Core.Models
{
public class AlbumGroupKey : IGroupKey
{
Expand Down
5 changes: 3 additions & 2 deletions BreadPlayer.Core/Models/Mediafile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ You should have received a copy of the GNU General Public License
*/

using BreadPlayer.Core.Common;
using BreadPlayer.Interfaces;
using LiteDB;
using Newtonsoft.Json;
using System;

namespace BreadPlayer.Core.Models
{
public class Mediafile : ObservableObject, IComparable<Mediafile>, IDbRecord, ISelectable, IPinnable
public class Mediafile : ObservableObject, IComparable<IMediafile>, IDbRecord, ISelectable, IPinnable, IMediafile
{
#region Fields

Expand Down Expand Up @@ -196,7 +197,7 @@ public bool IsSelected

public string TextSearchKey => GetTextSearchKey().ToLower();

public int CompareTo(Mediafile compareTo)
public int CompareTo(IMediafile compareTo)
{
return Title.CompareTo(compareTo.Title);
}
Expand Down
Loading

0 comments on commit 4ff0a3d

Please sign in to comment.