mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
Code quality pass
This commit is contained in:
parent
16bbf8c755
commit
2feb1f2718
41 changed files with 153 additions and 278 deletions
|
@ -21,7 +21,7 @@ namespace FRESHMusicPlayer
|
|||
{
|
||||
DataContext = new MainWindowViewModel(),
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
Name = MainWindowViewModel.ProjectName;
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
|
|
|
@ -3,13 +3,8 @@ using Avalonia.Platform;
|
|||
using Avalonia.Rendering.SceneGraph;
|
||||
using Avalonia.Skia;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Controls.BlurryImage
|
||||
{
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Controls.BlurryImage
|
||||
{
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
using Avalonia.Platform;
|
||||
using Avalonia.Rendering.SceneGraph;
|
||||
using Avalonia.Skia;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Controls.BlurryImage
|
||||
{
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using FRESHMusicPlayer.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Configuration
|
||||
{
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Configuration
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.DatabaseIntegrations
|
||||
{
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.DatabaseIntegrations
|
||||
{
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.DatabaseIntegrations
|
||||
{
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
using ATL;
|
||||
using DiscordRPC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Integrations
|
||||
{
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using ATL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Integrations
|
||||
{
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
using ATL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Integrations
|
||||
{
|
||||
|
|
|
@ -4,9 +4,7 @@ using FRESHMusicPlayer.ViewModels;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tmds.DBus;
|
||||
using Drawing = SixLabors.ImageSharp;
|
||||
|
@ -50,7 +48,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations
|
|||
|
||||
public void Update(Track track, PlaybackStatus status)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +83,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations
|
|||
}
|
||||
|
||||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
// tmds.dbus requires that methods are async even if they don't need to
|
||||
// tmds.dbus requires that methods are async even if they don't need to
|
||||
class MediaPlayer2 : IMediaPlayer2, IPlayer
|
||||
{
|
||||
public event Action<PropertyChanges> OnPropertiesChanged;
|
||||
|
@ -213,7 +211,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations
|
|||
{"xesam:trackNumber", track.TrackNumber }
|
||||
};
|
||||
|
||||
if (viewModel.Config.MPRISShowCoverArt && track.EmbeddedPictures.Count >= 0)
|
||||
if (Program.Config.MPRISShowCoverArt && track.EmbeddedPictures.Count >= 0)
|
||||
{
|
||||
var runtimeDir = Environment.GetEnvironmentVariable("XDG_RUNTIME_DIR");
|
||||
var tempPath = Path.Combine(runtimeDir, "fmp");
|
||||
|
|
|
@ -3,9 +3,6 @@ using Newtonsoft.Json;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Integrations
|
||||
{
|
||||
|
@ -54,7 +51,7 @@ namespace FRESHMusicPlayer.Handlers.Integrations
|
|||
|
||||
public void Update(Track track, PlaybackStatus status)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers
|
||||
{
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Lyrics
|
||||
{
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Lyrics
|
||||
{
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Notifications
|
||||
{
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Handlers.Notifications
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.ReactiveUI;
|
||||
using FRESHMusicPlayer;
|
||||
using FRESHMusicPlayer.Handlers.Configuration;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
|
@ -26,7 +24,7 @@ namespace FRESHMusicPlayer
|
|||
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
using Desktop.DBus;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Desktop.DBus;
|
||||
using JetBrains.Annotations;
|
||||
using Tmds.DBus;
|
||||
|
||||
namespace FRESHMusicPlayer.Utilities
|
||||
|
@ -27,15 +26,15 @@ namespace FRESHMusicPlayer.Utilities
|
|||
var request = Connection.Session.CreateProxy<IRequest>("org.freedesktop.portal.Desktop", requestObjectPath);
|
||||
await request.WatchResponseAsync((args =>
|
||||
{
|
||||
completionSource.TrySetResult((string[]) args.results["uris"]);
|
||||
completionSource.TrySetResult((string[])args.results["uris"]);
|
||||
}));
|
||||
|
||||
var uris = await completionSource.Task;
|
||||
|
||||
|
||||
return uris.Select(uri => new Uri(uri).LocalPath).ToArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static async Task<string> SaveFile(string windowTitle, IDictionary<string, object> options)
|
||||
{
|
||||
var fileChooser = Connection.Session.CreateProxy<IFileChooser>("org.freedesktop.portal.Desktop",
|
||||
|
@ -47,7 +46,7 @@ namespace FRESHMusicPlayer.Utilities
|
|||
var request = Connection.Session.CreateProxy<IRequest>("org.freedesktop.portal.Desktop", requestObjectPath);
|
||||
await request.WatchResponseAsync((args =>
|
||||
{
|
||||
completionSource.TrySetResult((string[]) args.results["uris"]);
|
||||
completionSource.TrySetResult((string[])args.results["uris"]);
|
||||
}));
|
||||
|
||||
var uris = await completionSource.Task;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.Utilities
|
||||
{
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ATL;
|
||||
using ATL;
|
||||
using Avalonia.Media.Imaging;
|
||||
using FRESHMusicPlayer.Handlers.Lyrics;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ using ATL.Playlist;
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using AvaloniaPrimatives = Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
|
@ -12,6 +11,8 @@ using FRESHMusicPlayer.Handlers;
|
|||
using FRESHMusicPlayer.Handlers.Configuration;
|
||||
using FRESHMusicPlayer.Handlers.Integrations;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using FRESHMusicPlayer.Properties;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using FRESHMusicPlayer.Views;
|
||||
using LiteDB;
|
||||
using ReactiveUI;
|
||||
|
@ -24,10 +25,6 @@ using System.Linq;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.Properties;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using FRESHMusicPlayer.Views.TagEditor;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
@ -36,19 +33,18 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
public Player Player { get; private set; }
|
||||
public Timer ProgressTimer { get; private set; } = new(100);
|
||||
public Library Library { get; private set; }
|
||||
public ConfigurationFile Config { get; set; }
|
||||
public Track CurrentTrack { get; private set; }
|
||||
public IntegrationHandler Integrations { get; private set; } = new();
|
||||
public NotificationHandler Notifications { get; private set; } = new();
|
||||
|
||||
private Window Window
|
||||
{
|
||||
get
|
||||
|
||||
private Window Window
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
return desktop.MainWindow;
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindowViewModel()
|
||||
|
@ -105,8 +101,8 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
this.RaisePropertyChanged(nameof(CurrentTime));
|
||||
this.RaisePropertyChanged(nameof(CurrentTimeSeconds));
|
||||
|
||||
if (Config.ShowTimeInWindow) WindowTitle = $"{CurrentTime:mm\\:ss}/{TotalTime:mm\\:ss} | {ProjectName}";
|
||||
if (Config.ShowRemainingProgress) this.RaisePropertyChanged(nameof(TotalTime));
|
||||
if (Program.Config.ShowTimeInWindow) WindowTitle = $"{CurrentTime:mm\\:ss}/{TotalTime:mm\\:ss} | {ProjectName}";
|
||||
if (Program.Config.ShowRemainingProgress) this.RaisePropertyChanged(nameof(TotalTime));
|
||||
|
||||
Player.AvoidNextQueue = false;
|
||||
}
|
||||
|
@ -218,7 +214,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
}
|
||||
public void PauseAfterCurrentTrackCommand() => PauseAfterCurrentTrack = !PauseAfterCurrentTrack;
|
||||
|
||||
public void ShowRemainingProgressCommand() => Config.ShowRemainingProgress = !Config.ShowRemainingProgress;
|
||||
public void ShowRemainingProgressCommand() => Program.Config.ShowRemainingProgress = !Program.Config.ShowRemainingProgress;
|
||||
|
||||
private void UpdatePausedState() => Paused = Player.Paused;
|
||||
|
||||
|
@ -230,7 +226,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
if (Player.FileLoaded)
|
||||
return Player.CurrentTime;
|
||||
else return TimeSpan.Zero;
|
||||
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
|
@ -246,7 +242,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
if (Player.FileLoaded)
|
||||
return Player.CurrentTime.TotalSeconds;
|
||||
else return 0;
|
||||
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
|
@ -358,14 +354,16 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
$"{ProjectName}\n" +
|
||||
$"{RuntimeInformation.FrameworkDescription}\n" +
|
||||
$"{Environment.OSVersion.VersionString}\n");
|
||||
|
||||
Player.SongChanged += Player_SongChanged;
|
||||
Player.SongStopped += Player_SongStopped;
|
||||
Player.SongException += Player_SongException;
|
||||
ProgressTimer.Elapsed += ProgressTimer_Elapsed; // TODO: put this in a more logical place
|
||||
ProgressTimer.Elapsed += ProgressTimer_Elapsed;
|
||||
Notifications.NotificationInvalidate += Notifications_NotificationInvalidate;
|
||||
|
||||
LoggingHandler.Log("Handling config...");
|
||||
Config = Program.Config; // HACK: this is a hack
|
||||
Volume = Config?.Volume ?? 1f;
|
||||
|
||||
Volume = Program.Config?.Volume ?? 1f;
|
||||
|
||||
LoggingHandler.Log("Handling command line args...");
|
||||
var args = Environment.GetCommandLineArgs().ToList();
|
||||
|
@ -377,22 +375,22 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Config.FilePath))
|
||||
if (!string.IsNullOrEmpty(Program.Config.FilePath))
|
||||
{
|
||||
PauseAfterCurrentTrack = true;
|
||||
Player.PlayMusic(Config.FilePath);
|
||||
Player.CurrentTime.Add(TimeSpan.FromSeconds(Config.FilePosition));
|
||||
Player.PlayMusic(Program.Config.FilePath);
|
||||
Player.CurrentTime.Add(TimeSpan.FromSeconds(Program.Config.FilePosition));
|
||||
}
|
||||
}
|
||||
await Dispatcher.UIThread.InvokeAsync(() => SelectedTab = Config.CurrentTab, DispatcherPriority.ApplicationIdle); // TODO: unhack the hack
|
||||
|
||||
if (Config.IntegrateDiscordRPC)
|
||||
await Dispatcher.UIThread.InvokeAsync(() => SelectedTab = Program.Config.CurrentTab, DispatcherPriority.ApplicationIdle);
|
||||
// this delays the tab switch until avalonia is ready
|
||||
if (Program.Config.IntegrateDiscordRPC)
|
||||
Integrations.Add(new DiscordIntegration());
|
||||
if (Config.PlaybackTracking)
|
||||
if (Program.Config.PlaybackTracking)
|
||||
Integrations.Add(new PlaytimeLoggingIntegration(Player));
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Config.IntegrateMPRIS)
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Program.Config.IntegrateMPRIS)
|
||||
Integrations.Add(new MPRISIntegration(this, Window));
|
||||
(GetMainWindow() as MainWindow).RootPanel.Opacity = 1;
|
||||
(GetMainWindow() as MainWindow).RootPanel.Opacity = 1; // this triggers the startup fade
|
||||
await PerformAutoImport();
|
||||
}
|
||||
|
||||
|
@ -415,25 +413,25 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
LoggingHandler.Log("FMP is shutting down!");
|
||||
Library?.Database.Dispose();
|
||||
Integrations.Dispose();
|
||||
Config.Volume = Volume;
|
||||
Config.CurrentTab = SelectedTab;
|
||||
Program.Config.Volume = Volume;
|
||||
Program.Config.CurrentTab = SelectedTab;
|
||||
if (Player.FileLoaded)
|
||||
{
|
||||
Config.FilePath = Player.FilePath;
|
||||
Config.FilePosition = Player.CurrentTime.TotalSeconds;
|
||||
Program.Config.FilePath = Player.FilePath;
|
||||
Program.Config.FilePosition = Player.CurrentTime.TotalSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
Config.FilePath = null;
|
||||
Program.Config.FilePath = null;
|
||||
}
|
||||
await ConfigurationHandler.Write(Config);
|
||||
await ConfigurationHandler.Write(Program.Config);
|
||||
LoggingHandler.Log("Goodbye!");
|
||||
}
|
||||
|
||||
public async Task PerformAutoImport()
|
||||
{
|
||||
if (Config.AutoImportPaths.Count <= 0) return; // not really needed but prevents going through unneeded
|
||||
// effort (and showing the notification)
|
||||
if (Program.Config.AutoImportPaths.Count <= 0) return; // not really needed but prevents going through unneeded
|
||||
// effort (and showing the notification)
|
||||
var notification = new Notification()
|
||||
{
|
||||
ContentText = Properties.Resources.Notification_Scanning
|
||||
|
@ -443,7 +441,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
var library = Library.Read();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (var folder in Config.AutoImportPaths)
|
||||
foreach (var folder in Program.Config.AutoImportPaths)
|
||||
{
|
||||
var files = Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories)
|
||||
.Where(name => name.EndsWith(".mp3")
|
||||
|
@ -535,7 +533,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
{
|
||||
if (playlist is null) return;
|
||||
AllTracks.Clear();
|
||||
foreach (var track in await Task.Run(() => Library.ReadTracksForPlaylist(playlist)))
|
||||
foreach (var track in await Task.Run(() => Library.ReadTracksForPlaylist(playlist)))
|
||||
AllTracks.Add(track);
|
||||
UpdateLibraryInfo();
|
||||
}
|
||||
|
@ -622,7 +620,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
}
|
||||
|
||||
private List<string> acceptableFilePaths = "wav;aiff;mp3;wma;3g2;3gp;3gp2;3gpp;asf;wmv;aac;adts;avi;m4a;m4a;m4v;mov;mp4;sami;smi;flac".Split(';').ToList();
|
||||
// ripped directly from fmp-wpf 'cause i'm lazy
|
||||
// ripped directly from fmp-wpf 'cause i'm lazy
|
||||
public async void BrowseTracksCommand()
|
||||
{
|
||||
if (await FreedesktopPortal.IsPortalAvailable())
|
||||
|
@ -643,7 +641,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
if (files.Length != 0) await Task.Run(() => Library.Import(files));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var dialog = new OpenFileDialog()
|
||||
{
|
||||
Filters = new List<FileDialogFilter>
|
||||
|
@ -666,13 +664,13 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
var files = await dialog.ShowAsync(desktop.MainWindow);
|
||||
if (files.Length > 0) await Task.Run(() => Library.Import(files));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public async void BrowsePlaylistFilesCommand()
|
||||
{
|
||||
string[] acceptableFiles = {"xspf", "asx", "wvx", "b4s", "m3u", "m3u8", "pls", "smil", "smi", "zpl"};
|
||||
string[] acceptableFiles = { "xspf", "asx", "wvx", "b4s", "m3u", "m3u8", "pls", "smil", "smi", "zpl" };
|
||||
string[] files = null;
|
||||
|
||||
|
||||
if (await FreedesktopPortal.IsPortalAvailable())
|
||||
{
|
||||
files = await FreedesktopPortal.OpenFiles(Resources.ImportPlaylistFiles, new Dictionary<string, object>()
|
||||
|
@ -706,8 +704,8 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
if (files is not {Length: > 0}) return;
|
||||
|
||||
if (files is not { Length: > 0 }) return;
|
||||
|
||||
var reader = PlaylistIOFactory.GetInstance().GetPlaylistIO(files[0]);
|
||||
foreach (var s in reader.FilePaths)
|
||||
{
|
||||
|
@ -740,7 +738,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
{"accept_label", Resources.ImportFolders},
|
||||
{"directory", true}
|
||||
});
|
||||
|
||||
|
||||
if (result.Length == 1)
|
||||
{
|
||||
directory = result[0];
|
||||
|
@ -756,15 +754,16 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
{
|
||||
var dialog = new OpenFolderDialog()
|
||||
{
|
||||
|
||||
|
||||
};
|
||||
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
directory = await dialog.ShowAsync(desktop.MainWindow);
|
||||
}
|
||||
}
|
||||
|
||||
if (directory != null) {
|
||||
|
||||
if (directory != null)
|
||||
{
|
||||
var paths = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories)
|
||||
.Where(name => name.EndsWith(".mp3")
|
||||
|| name.EndsWith(".wav") || name.EndsWith(".m4a") || name.EndsWith(".ogg")
|
||||
|
@ -829,7 +828,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
#region NavBar
|
||||
public void OpenSettingsCommand()
|
||||
{
|
||||
new Views.Settings().SetThings(Config, Library).Show(Window);
|
||||
new Views.Settings().SetThings(Program.Config, Library).Show(Window);
|
||||
}
|
||||
|
||||
public void OpenQueueManagementCommand()
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ATL.Playlist;
|
||||
using ATL.Playlist;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
|
@ -15,6 +7,13 @@ using FRESHMusicPlayer.Properties;
|
|||
using FRESHMusicPlayer.Utilities;
|
||||
using FRESHMusicPlayer.Views;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
@ -84,14 +83,13 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public async void RenamePlaylistCommand(string playlist)
|
||||
{
|
||||
var dialog = new TextEntryBox().SetStuff(Properties.Resources.PlaylistManagement_PlaylistName);
|
||||
(dialog.DataContext as TextEntryBoxViewModel).Text = playlist;
|
||||
var dialog = new TextEntryBox().SetStuff(Resources.PlaylistManagement_PlaylistName, playlist);
|
||||
await dialog.ShowDialog(GetMainWindow());
|
||||
|
||||
if (dialog.OK)
|
||||
{
|
||||
var x = MainWindow.Library.Database.GetCollection<DatabasePlaylist>("playlists").FindOne(y => y.Name == playlist);
|
||||
x.Name = (dialog.DataContext as TextEntryBoxViewModel).Text;
|
||||
x.Name = dialog.Text;
|
||||
MainWindow.Library.Database.GetCollection<DatabasePlaylist>("playlists").Update(x);
|
||||
Initialize();
|
||||
}
|
||||
|
@ -149,11 +147,11 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
if (dialog.OK)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace((dialog.DataContext as TextEntryBoxViewModel).Text))
|
||||
if (string.IsNullOrWhiteSpace(dialog.Text))
|
||||
new MessageBox().SetStuff(Properties.Resources.PlaylistManagement_InvalidName).Show(GetMainWindow());
|
||||
else
|
||||
{
|
||||
MainWindow.Library.CreatePlaylist((dialog.DataContext as TextEntryBoxViewModel).Text, Track);
|
||||
MainWindow.Library.CreatePlaylist(dialog.Text, Track);
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
|
@ -161,10 +159,10 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public async void ImportCommand()
|
||||
{
|
||||
|
||||
string[] acceptableFiles = {"xspf", "asx", "wvx", "b4s", "m3u", "m3u8", "pls", "smil", "smi", "zpl"};
|
||||
|
||||
string[] acceptableFiles = { "xspf", "asx", "wvx", "b4s", "m3u", "m3u8", "pls", "smil", "smi", "zpl" };
|
||||
string[] files = null;
|
||||
|
||||
|
||||
if (await FreedesktopPortal.IsPortalAvailable())
|
||||
{
|
||||
files = await FreedesktopPortal.OpenFiles(Resources.ImportPlaylistFiles, new Dictionary<string, object>()
|
||||
|
@ -195,8 +193,8 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
files = await dialog.ShowAsync(GetMainWindow());
|
||||
}
|
||||
|
||||
if (files is not {Length: > 0}) return;
|
||||
|
||||
if (files is not { Length: > 0 }) return;
|
||||
|
||||
IPlaylistIO reader = PlaylistIOFactory.GetInstance().GetPlaylistIO(files[0]);
|
||||
foreach (string s in reader.FilePaths)
|
||||
{
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
using FRESHMusicPlayer.Handlers;
|
||||
using ATL.Playlist;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Threading;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ReactiveUI;
|
||||
using System.Timers;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using ATL.Playlist;
|
||||
using System.IO;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
@ -143,7 +141,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
|
||||
|
||||
TimeSpan x = new();
|
||||
int i = 1;
|
||||
int i2 = 0;
|
||||
|
@ -174,7 +172,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
private void Queue_QueueChanged(object sender, EventArgs e) => Update();
|
||||
}
|
||||
|
||||
|
||||
public class QueueManagementEntry
|
||||
{
|
||||
public string Title { get; init; }
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
using FRESHMusicPlayer.Handlers.Configuration;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.Configuration;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FRESHMusicPlayer.Views;
|
||||
using ReactiveUI;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ReactiveUI;
|
||||
using System.Collections.ObjectModel;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using Avalonia.Controls;
|
||||
using FRESHMusicPlayer.Views;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
@ -137,7 +135,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public SettingsViewModel()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void StartThings()
|
||||
|
@ -184,10 +182,8 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public void ResetSettingsCommand()
|
||||
{
|
||||
var mainWindow = GetMainWindow().DataContext as MainWindowViewModel; // little messy, maybe figure out how to make this cleaner
|
||||
mainWindow.Config = new ConfigurationFile();
|
||||
Program.Config = mainWindow.Config;
|
||||
Config = mainWindow.Config;
|
||||
Program.Config = new ConfigurationFile();
|
||||
Config = Program.Config;
|
||||
StartThings();
|
||||
}
|
||||
public async void CleanLibraryCommand()
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
using Avalonia.Controls;
|
||||
using FRESHMusicPlayer.Views.TagEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FRESHMusicPlayer.Views.TagEditor;
|
||||
using ReactiveUI;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels.TagEditor
|
||||
{
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
using ATL;
|
||||
using Avalonia.Controls;
|
||||
using FRESHMusicPlayer.Handlers.DatabaseIntegrations;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using FRESHMusicPlayer.Views.TagEditor;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels.TagEditor
|
||||
{
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ATL;
|
||||
using ATL;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Metadata;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.DatabaseIntegrations;
|
||||
using FRESHMusicPlayer.Properties;
|
||||
|
@ -17,6 +8,12 @@ using FRESHMusicPlayer.Utilities;
|
|||
using FRESHMusicPlayer.Views;
|
||||
using FRESHMusicPlayer.Views.TagEditor;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Drawing = SixLabors.ImageSharp;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels.TagEditor
|
||||
|
@ -47,7 +44,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string Title
|
||||
{
|
||||
get => title;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref title, value);
|
||||
UnsavedChanges = true;
|
||||
|
@ -57,7 +54,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string Year
|
||||
{
|
||||
get => year;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref year, value);
|
||||
UnsavedChanges = true;
|
||||
|
@ -67,7 +64,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string Genre
|
||||
{
|
||||
get => genre;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref genre, value);
|
||||
UnsavedChanges = true;
|
||||
|
@ -77,7 +74,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string Album
|
||||
{
|
||||
get => album;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref album, value);
|
||||
UnsavedChanges = true;
|
||||
|
@ -88,7 +85,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string AlbumArtist
|
||||
{
|
||||
get => albumArtist;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref albumArtist, value);
|
||||
UnsavedChanges = true;
|
||||
|
@ -98,7 +95,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string Composer
|
||||
{
|
||||
get => composer;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref composer, value);
|
||||
UnsavedChanges = true;
|
||||
|
@ -108,7 +105,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string TrackNumber
|
||||
{
|
||||
get => trackNumber;
|
||||
set
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref trackNumber, value);
|
||||
UnsavedChanges = true;
|
||||
|
@ -197,7 +194,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
}
|
||||
|
||||
if (files == null) return;
|
||||
|
||||
|
||||
CoverArts[SelectedCoverArt] = PictureInfo.fromBinaryData(File.ReadAllBytes(files[0]), CoverArts[SelectedCoverArt].PicType);
|
||||
ChangeCoverArt();
|
||||
UnsavedChanges = true;
|
||||
|
@ -374,7 +371,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
};
|
||||
files = await dialog.ShowAsync(Window);
|
||||
}
|
||||
|
||||
|
||||
Initialize(files.ToList());
|
||||
}
|
||||
|
||||
|
@ -424,7 +421,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
await dialog.ShowDialog(Window);
|
||||
if (!dialog.OK) return;
|
||||
|
||||
string query = (dialog.DataContext as TextEntryBoxViewModel).Text; // TODO: fix this mess
|
||||
string query = dialog.Text;
|
||||
var results = integration.Search(query);
|
||||
|
||||
var index = 0;
|
||||
|
@ -449,7 +446,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
var filePath = FilePaths[0];
|
||||
var release = integration.Fetch(results[index].Id);
|
||||
var editor = new ReleaseIntegrationPage().SetStuff(release, new Track(filePath));
|
||||
await editor .ShowDialog(Window);
|
||||
await editor.ShowDialog(Window);
|
||||
if (editor.OK)
|
||||
{
|
||||
Artist = editor.TrackToSave.Artist;
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
using Avalonia.Media.Imaging;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
@ -43,7 +39,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
private string trackNumberText;
|
||||
public string TrackNumberText
|
||||
{
|
||||
get => trackNumberText;
|
||||
get => trackNumberText;
|
||||
set => this.RaiseAndSetIfChanged(ref trackNumberText, value);
|
||||
}
|
||||
private bool trackNumberShouldBeVisible = true;
|
||||
|
@ -81,7 +77,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
|
||||
public TrackInfoViewModel()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void StartThings()
|
||||
|
@ -108,7 +104,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
BitrateText = $"{track.Bitrate}kbps {track.SampleRate / 1000}kHz";
|
||||
|
||||
if (track.DiscNumber == 0) DiscNumberShouldBeVisible = false;
|
||||
else DiscNumberText = track.DiscTotal <= 0 ? track.DiscNumber.ToString() : $"{track.DiscNumber}/{track.DiscTotal}";
|
||||
else DiscNumberText = track.DiscTotal <= 0 ? track.DiscNumber.ToString() : $"{track.DiscNumber}/{track.DiscTotal}";
|
||||
|
||||
if (track.TrackNumber == 0) TrackNumberShouldBeVisible = false;
|
||||
else TrackNumberText = track.TrackTotal <= 0 ? track.TrackNumber.ToString() : $"{track.TrackNumber}/{track.TrackTotal}";
|
||||
|
|
|
@ -2,8 +2,6 @@ using Avalonia.Controls;
|
|||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FRESHMusicPlayer.ViewModels
|
||||
{
|
||||
|
|
|
@ -4,17 +4,12 @@ using Avalonia.Input;
|
|||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using System.Linq;
|
||||
|
||||
namespace FRESHMusicPlayer.Views
|
||||
{
|
||||
|
@ -52,11 +47,11 @@ namespace FRESHMusicPlayer.Views
|
|||
|
||||
private void OnInitialized(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OpenTrackInfo(object sender, PointerPressedEventArgs e) // HACK: THIS SHOULD NOT BE IN THE
|
||||
{ // CODE BEHIND!!!!
|
||||
private void OpenTrackInfo(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||
ActualOpenTrackInfo();
|
||||
}
|
||||
|
@ -211,5 +206,5 @@ namespace FRESHMusicPlayer.Views
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ using Avalonia.Controls;
|
|||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
using System;
|
||||
|
||||
namespace FRESHMusicPlayer.Views
|
||||
{
|
||||
|
@ -22,7 +21,7 @@ namespace FRESHMusicPlayer.Views
|
|||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
public MessageBox SetStuff(
|
||||
|
|
|
@ -2,7 +2,6 @@ using Avalonia;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.ViewModels;
|
||||
using System;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace FRESHMusicPlayer.Views
|
|||
ViewModel?.JumpToCommand(x.Position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnRemoveButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var cmd = (Button)sender;
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace FRESHMusicPlayer.Views
|
|||
public Settings()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
public Settings SetThings(ConfigurationFile config, Library library)
|
||||
|
@ -29,7 +29,7 @@ namespace FRESHMusicPlayer.Views
|
|||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.ViewModels.TagEditor;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using System.ComponentModel;
|
||||
using FRESHMusicPlayer.ViewModels.TagEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace FRESHMusicPlayer.Views.TagEditor
|
||||
{
|
||||
|
|
|
@ -9,6 +9,9 @@ namespace FRESHMusicPlayer.Views
|
|||
public partial class TextEntryBox : Window
|
||||
{
|
||||
public bool OK { get; private set; } = false;
|
||||
public string Text => ViewModel.Text;
|
||||
|
||||
private TextEntryBoxViewModel ViewModel => DataContext as TextEntryBoxViewModel;
|
||||
|
||||
public TextEntryBox()
|
||||
{
|
||||
|
@ -20,9 +23,8 @@ namespace FRESHMusicPlayer.Views
|
|||
|
||||
public TextEntryBox SetStuff(string header, string initialText = "")
|
||||
{
|
||||
var context = DataContext as TextEntryBoxViewModel;
|
||||
context.Header = header;
|
||||
context.Text = initialText;
|
||||
ViewModel.Header = header;
|
||||
ViewModel.Text = initialText;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue