Merge remote-tracking branch 'origin/main' into j.lechner/openverse
# Conflicts: # src/Radiosender/Views/MainWindow.xaml
This commit is contained in:
commit
ba97d351b0
7 files changed
+296
No files matched your search
@@ -0,0 +1,19 @@
|
||||
<Page x:Class="Radiosender.Views.Pages.UploadPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
Title="Upload">
|
||||
<Grid>
|
||||
<StackPanel Margin="24">
|
||||
<ui:TextBlock FontTypography="Title" Text="Upload" />
|
||||
<ui:TextBlock Margin="0,8,0,0" Text="Add an MP3 or WAV file from your computer to the library." />
|
||||
<ui:Button x:Name="ChooseFileButton"
|
||||
Margin="0,16,0,0"
|
||||
Appearance="Primary"
|
||||
Content="Choose file..."
|
||||
Icon="{ui:SymbolIcon ArrowUpload24}"
|
||||
Click="ChooseFileButton_Click" />
|
||||
</StackPanel>
|
||||
<ui:SnackbarPresenter x:Name="SnackbarPresenter" VerticalAlignment="Bottom" />
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Windows;
|
||||
using Microsoft.Win32;
|
||||
using Radiosender.Controllers;
|
||||
using Radiosender.Services;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace Radiosender.Views.Pages;
|
||||
|
||||
public partial class UploadPage
|
||||
{
|
||||
private readonly UploadController _controller =
|
||||
new(new SongImportService(App.Songs, SongImportService.DefaultMusicDirectory));
|
||||
|
||||
public UploadPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ChooseFileButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog { Filter = UploadController.FileDialogFilter };
|
||||
if (dialog.ShowDialog() != true)
|
||||
return;
|
||||
|
||||
var result = _controller.Upload(dialog.FileName);
|
||||
new Snackbar(SnackbarPresenter)
|
||||
{
|
||||
Title = result.Success ? "Song uploaded" : "Upload failed",
|
||||
Content = result.Message,
|
||||
Appearance = result.Success ? ControlAppearance.Success : ControlAppearance.Danger,
|
||||
Icon = new SymbolIcon(result.Success ? SymbolRegular.CheckmarkCircle24 : SymbolRegular.ErrorCircle24),
|
||||
Timeout = TimeSpan.FromSeconds(5),
|
||||
}.Show();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user