Enable drag and drop support

This commit is contained in:
Matt Nadareski
2021-06-29 21:00:34 -07:00
parent 9147fe7da7
commit c6f1523dd1
4 changed files with 62 additions and 31 deletions

View File

@@ -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>