mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Enable drag and drop support
This commit is contained in:
@@ -58,6 +58,29 @@ namespace RedBookPlayer.GUI
|
||||
return (await dialog.ShowAsync((Window)Parent.Parent))?.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an image from the path
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the image to load</param>
|
||||
public async Task<bool> LoadImage(string path)
|
||||
{
|
||||
bool result = await Task.Run(() =>
|
||||
{
|
||||
Player.Init(path, App.Settings.AutoPlay);
|
||||
return Player.Initialized;
|
||||
});
|
||||
|
||||
if(result)
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
MainWindow.Instance.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the png image for a given character based on the theme
|
||||
/// </summary>
|
||||
@@ -90,6 +113,7 @@ namespace RedBookPlayer.GUI
|
||||
{
|
||||
DataContext = new PlayerViewModel();
|
||||
|
||||
// Load the theme
|
||||
if (xaml != null)
|
||||
new AvaloniaXamlLoader().Load(xaml, null, this);
|
||||
else
|
||||
@@ -150,27 +174,6 @@ namespace RedBookPlayer.GUI
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an image from the path
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the image to load</param>
|
||||
private async void LoadImage(string path)
|
||||
{
|
||||
bool result = await Task.Run(() =>
|
||||
{
|
||||
Player.Init(path, App.Settings.AutoPlay);
|
||||
return Player.Initialized;
|
||||
});
|
||||
|
||||
if(result)
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
MainWindow.Instance.Title = "RedBookPlayer - " + path.Split('/').Last().Split('\\').Last();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the UI with the most recent information from the Player
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user