mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
bunch of cool things
This commit is contained in:
parent
03f4829fb5
commit
4a78df7ed9
7 changed files with 118 additions and 32 deletions
|
@ -389,6 +389,7 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
Integrations.Add(new PlaytimeLoggingIntegration(Player));
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Config.IntegrateMPRIS)
|
||||
Integrations.Add(new MPRISIntegration(this, Window));
|
||||
(GetMainWindow() as MainWindow).RootPanel.Opacity = 1;
|
||||
await PerformAutoImport();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
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 Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using FRESHMusicPlayer.Views;
|
||||
|
@ -182,4 +184,20 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
public string ThingName { get; init; } // bit hacky but it works lol
|
||||
public bool ShouldThingBeVisible { get; init; }
|
||||
}
|
||||
|
||||
public class AndValueConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var x = values[0];
|
||||
var z = values[1];
|
||||
if (x is bool object1 && z is bool object2) return object1 && object2;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public object ConvertBack(List<object> value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,56 +20,92 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
public string Artist
|
||||
{
|
||||
get => artist;
|
||||
set => this.RaiseAndSetIfChanged(ref artist, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref artist, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
private string title;
|
||||
public string Title
|
||||
{
|
||||
get => title;
|
||||
set => this.RaiseAndSetIfChanged(ref title, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref title, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
private string year;
|
||||
public string Year
|
||||
{
|
||||
get => year;
|
||||
set => this.RaiseAndSetIfChanged(ref year, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref year, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
private string genre;
|
||||
public string Genre
|
||||
{
|
||||
get => genre;
|
||||
set => this.RaiseAndSetIfChanged(ref genre, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref genre, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
private string album;
|
||||
public string Album
|
||||
{
|
||||
get => album;
|
||||
set => this.RaiseAndSetIfChanged(ref album, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref album, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
private string albumArtist;
|
||||
public string AlbumArtist
|
||||
{
|
||||
get => albumArtist;
|
||||
set => this.RaiseAndSetIfChanged(ref albumArtist, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref albumArtist, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
private string composer;
|
||||
public string Composer
|
||||
{
|
||||
get => composer;
|
||||
set => this.RaiseAndSetIfChanged(ref composer, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref composer, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
private string trackNumber;
|
||||
public string TrackNumber
|
||||
{
|
||||
get => trackNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref trackNumber, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref trackNumber, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
private string discNumber;
|
||||
public string DiscNumber
|
||||
{
|
||||
get => discNumber;
|
||||
set => this.RaiseAndSetIfChanged(ref discNumber, value);
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref discNumber, value);
|
||||
UnsavedChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> FilePaths { get; private set; } = new();
|
||||
|
@ -84,13 +120,13 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
if (FilePaths.Count > 0)
|
||||
{
|
||||
initialString = $"{string.Join(", ", FilePaths)} | {windowName}";
|
||||
if (UnsavedChanges) initialString = $"*{initialString}";
|
||||
return initialString;
|
||||
}
|
||||
else
|
||||
{
|
||||
initialString = windowName;
|
||||
return windowName;
|
||||
}
|
||||
if (UnsavedChanges) initialString = $"*{initialString}";
|
||||
return initialString;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +137,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref unsavedChanges, value);
|
||||
// TODO: asterisk thing
|
||||
this.RaisePropertyChanged(nameof(WindowTitle));
|
||||
}
|
||||
}
|
||||
private bool isBackgroundSaveNeeded = false;
|
||||
|
@ -128,6 +164,7 @@ namespace FRESHMusicPlayer.ViewModels.TagEditor
|
|||
TrackNumber = track.TrackNumber.ToString();
|
||||
DiscNumber = track.DiscNumber.ToString();
|
||||
}
|
||||
UnsavedChanges = false; // override setting these usually making unsaved changes true, kinda jank but it works lol
|
||||
}
|
||||
|
||||
public void NewWindowCommand()
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
Width="800" Height="540"
|
||||
x:Class="FRESHMusicPlayer.Views.MainWindow"
|
||||
DragDrop.AllowDrop="True"
|
||||
Icon="/Assets/icon.ico" Closing="OnClosing" PointerWheelChanged="OnPointerWheelChanged" KeyDown="OnKeyDown"
|
||||
Icon="/Assets/icon.ico" Closing="OnClosing" PointerWheelChanged="OnPointerWheelChanged" KeyDown="OnKeyDown" Initialized="OnInitialized"
|
||||
Title="{Binding WindowTitle}"
|
||||
>
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
<vm:TotalTimeDisplayConverter x:Key="TotalTimeDisplayConverter"/>
|
||||
</Window.Resources>
|
||||
<Window.Styles>
|
||||
|
||||
|
||||
</Window.Styles>
|
||||
|
||||
<Design.DataContext>
|
||||
|
@ -83,7 +83,7 @@
|
|||
</NativeMenuItem>
|
||||
</NativeMenu>
|
||||
</NativeMenu.Menu>
|
||||
<Panel x:Name="RootPanel" DragDrop.AllowDrop="True">
|
||||
<Panel x:Name="RootPanel" DragDrop.AllowDrop="True" Opacity="0">
|
||||
<StackPanel Background="Transparent" Orientation="Horizontal" ZIndex="1" Height="35" Margin="0,0,10,0" VerticalAlignment="Top" HorizontalAlignment="Right">
|
||||
<Button x:Name="SearchButton" Margin="0,5" Click="OnSearchButtonClick">
|
||||
<Button.ContextFlyout>
|
||||
|
@ -227,7 +227,7 @@
|
|||
</Slider>
|
||||
<Image Grid.Column="1" Source="{DynamicResource Volume}"/>
|
||||
</Grid>
|
||||
|
||||
|
||||
<StackPanel Grid.Row="2" VerticalAlignment="Center" Orientation="Horizontal" Margin="10,0">
|
||||
<Button x:Name="PreviousTrackButton" Command="{Binding SkipPreviousCommand}">
|
||||
<Image Source="{DynamicResource SkipPrevious}"/>
|
||||
|
@ -265,7 +265,7 @@
|
|||
<DockPanel>
|
||||
<DockPanel DockPanel.Dock="Bottom" Margin="0,5,0,0" LastChildFill="False">
|
||||
<TextBlock DockPanel.Dock="Left" VerticalAlignment="Center" Text="{Binding LibraryInfoText}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}" Margin="10,0,0,0"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding EnqueueAllCommand}" Content="{x:Static resx:Resources.Library_EnqueueAll}"/>
|
||||
</DockPanel>
|
||||
<ListBox Items="{Binding AllTracks}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="AlwaysSelected" VirtualizationMode="Simple">
|
||||
|
@ -313,7 +313,7 @@
|
|||
</ListBox>
|
||||
<DockPanel DockPanel.Dock="Bottom" Margin="10,5,0,0" LastChildFill="False">
|
||||
<TextBlock DockPanel.Dock="Left" VerticalAlignment="Center" Text="{Binding LibraryInfoText}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}" Margin="10,0,0,0"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding EnqueueAllCommand}" Content="{x:Static resx:Resources.Library_EnqueueAll}"/>
|
||||
</DockPanel>
|
||||
<ListBox Items="{Binding AllTracks}" Margin="10,0,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="AlwaysSelected" VirtualizationMode="Simple">
|
||||
|
@ -361,7 +361,7 @@
|
|||
</ListBox>
|
||||
<DockPanel DockPanel.Dock="Bottom" Margin="10,5,0,0" LastChildFill="False">
|
||||
<TextBlock DockPanel.Dock="Left" VerticalAlignment="Center" Text="{Binding LibraryInfoText}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}" Margin="10,0,0,0"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding EnqueueAllCommand}" Content="{x:Static resx:Resources.Library_EnqueueAll}"/>
|
||||
</DockPanel>
|
||||
<ListBox Items="{Binding AllTracks}" Margin="10,0,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="AlwaysSelected" VirtualizationMode="Simple">
|
||||
|
@ -409,7 +409,7 @@
|
|||
</ListBox>
|
||||
<DockPanel DockPanel.Dock="Bottom" Margin="10,5,0,0" LastChildFill="False">
|
||||
<TextBlock DockPanel.Dock="Left" VerticalAlignment="Center" Text="{Binding LibraryInfoText}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding PlayAllCommand}" Content="{x:Static resx:Resources.Library_PlayAll}" Margin="10,0,0,0"/>
|
||||
<Button DockPanel.Dock="Right" Command="{Binding EnqueueAllCommand}" Content="{x:Static resx:Resources.Library_EnqueueAll}"/>
|
||||
</DockPanel>
|
||||
<ListBox Items="{Binding AllTracks}" Margin="10,0,0,0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectionMode="AlwaysSelected" VirtualizationMode="Simple">
|
||||
|
@ -461,6 +461,11 @@
|
|||
</TabControl>
|
||||
</DockPanel>
|
||||
|
||||
<Panel.Transitions>
|
||||
<Transitions>
|
||||
<DoubleTransition Property="Opacity" Duration="0:0:2" Easing="ExponentialEaseOut"/>
|
||||
</Transitions>
|
||||
</Panel.Transitions>
|
||||
</Panel>
|
||||
|
||||
</Window>
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace FRESHMusicPlayer.Views
|
|||
public class MainWindow : Window
|
||||
{
|
||||
private MainWindowViewModel ViewModel { get => DataContext as MainWindowViewModel; }
|
||||
public Panel RootPanel { get; private set; }
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -28,11 +29,11 @@ namespace FRESHMusicPlayer.Views
|
|||
this.AttachDevTools();
|
||||
#endif
|
||||
DoStuff();
|
||||
var rootPanel = this.FindControl<Panel>("RootPanel");
|
||||
DragDrop.SetAllowDrop(rootPanel, true);
|
||||
rootPanel.AddHandler(DragDrop.DragEnterEvent, OnDragEnter);
|
||||
rootPanel.AddHandler(DragDrop.DragOverEvent, OnDragEnter);
|
||||
rootPanel.AddHandler(DragDrop.DropEvent, OnDragDrop);
|
||||
RootPanel = this.FindControl<Panel>("RootPanel");
|
||||
DragDrop.SetAllowDrop(RootPanel, true);
|
||||
RootPanel.AddHandler(DragDrop.DragEnterEvent, OnDragEnter);
|
||||
RootPanel.AddHandler(DragDrop.DragOverEvent, OnDragEnter);
|
||||
RootPanel.AddHandler(DragDrop.DropEvent, OnDragDrop);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
|
@ -50,6 +51,11 @@ namespace FRESHMusicPlayer.Views
|
|||
ViewModel?.CloseThings();
|
||||
}
|
||||
|
||||
private void OnInitialized(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OpenTrackInfo(object sender, PointerPressedEventArgs e) // HACK: THIS SHOULD NOT BE IN THE
|
||||
{ // CODE BEHIND!!!!
|
||||
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
</Window.Styles>
|
||||
<Window.Resources>
|
||||
<vm:AndValueConverter x:Key="AndValueConverter"/>
|
||||
</Window.Resources>
|
||||
<DockPanel>
|
||||
<DockPanel DockPanel.Dock="Bottom" Background="{StaticResource ForegroundColor}" LastChildFill="False">
|
||||
<Button DockPanel.Dock="Right" Margin="10" Click="OnOKButtonClick">OK</Button>
|
||||
|
@ -44,8 +47,14 @@
|
|||
<Button IsEnabled="{Binding !IsSelectedTrackHere}" Click="OnAddButtonClick" IsVisible="{Binding $parent[1].IsPointerOver}">
|
||||
<TextBlock Text="+"/>
|
||||
</Button>
|
||||
<Button IsVisible="{Binding $parent[1].IsPointerOver}" IsEnabled="{Binding ShouldThingBeVisible}" Click="OnAddThingButtonClick">
|
||||
<Button Click="OnAddThingButtonClick">
|
||||
<TextBlock Text="{Binding ThingName}" />
|
||||
<Button.IsVisible>
|
||||
<MultiBinding Converter="{StaticResource AndValueConverter}">
|
||||
<Binding Path="$parent[1].IsPointerOver"/>
|
||||
<Binding Path="ShouldThingBeVisible"/>
|
||||
</MultiBinding>
|
||||
</Button.IsVisible>
|
||||
</Button>
|
||||
<Button IsVisible="{Binding $parent[1].IsPointerOver}" Click="OnMiscButtonClick">
|
||||
<TextBlock Text="・・・"/>
|
||||
|
|
|
@ -3,11 +3,14 @@ using Avalonia.Controls;
|
|||
using Avalonia.Markup.Xaml;
|
||||
using FRESHMusicPlayer.ViewModels.TagEditor;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace FRESHMusicPlayer.Views.TagEditor
|
||||
{
|
||||
public partial class TagEditor : Window
|
||||
{
|
||||
private TagEditorViewModel ViewModel => DataContext as TagEditorViewModel;
|
||||
|
||||
public TagEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -18,13 +21,20 @@ namespace FRESHMusicPlayer.Views.TagEditor
|
|||
|
||||
public TagEditor SetStuff(Player player = null, Library library = null)
|
||||
{
|
||||
var dataContext = DataContext as TagEditorViewModel;
|
||||
dataContext.Player = player;
|
||||
dataContext.Library = library;
|
||||
dataContext.Window = this;
|
||||
ViewModel.Player = player;
|
||||
ViewModel.Library = library;
|
||||
ViewModel.Window = this;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (ViewModel.UnsavedChanges)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
|
Loading…
Reference in a new issue