mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
Merge branch 'master' of https://github.com/royce551/freshmusicplayer
This commit is contained in:
commit
f35855ba87
9 changed files with 121 additions and 98 deletions
|
@ -58,12 +58,12 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
public IntegrationHandler Integrations { get; private set; } = new();
|
||||
public NotificationHandler Notifications { get; private set; } = new();
|
||||
|
||||
private Window Window
|
||||
private MainWindow Window
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
return desktop.MainWindow;
|
||||
return desktop.MainWindow as MainWindow;
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
|
@ -407,43 +407,35 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
{
|
||||
get
|
||||
{
|
||||
switch (SelectedPane)
|
||||
return SelectedPane switch // TODO: convert to switch expression
|
||||
{
|
||||
case Pane.Settings:
|
||||
return new Views.Settings().SetThings(Program.Config, Library);
|
||||
case Pane.QueueManagement:
|
||||
return new Views.QueueManagement().SetStuff(Player, Library, ProgressTimer);
|
||||
case Pane.Search:
|
||||
return new UserControl
|
||||
Pane.Settings => new Views.Settings().SetThings(Program.Config, Library),
|
||||
Pane.QueueManagement => new Views.QueueManagement().SetStuff(Player, Library, ProgressTimer),
|
||||
Pane.Search => new UserControl
|
||||
{
|
||||
Content = new TextBlock
|
||||
{
|
||||
Content = new TextBlock
|
||||
{
|
||||
Text = "Search"
|
||||
}
|
||||
};
|
||||
case Pane.TrackInfo:
|
||||
return new TrackInfo().SetStuff(Player);
|
||||
case Pane.Notifications:
|
||||
return new UserControl
|
||||
Text = "Search"
|
||||
}
|
||||
},
|
||||
Pane.TrackInfo => new TrackInfo().SetStuff(Player),
|
||||
Pane.Notifications => new UserControl
|
||||
{
|
||||
Content = new TextBlock
|
||||
{
|
||||
Content = new TextBlock
|
||||
{
|
||||
Text = "Notifications"
|
||||
}
|
||||
};
|
||||
case Pane.Lyrics:
|
||||
return new UserControl
|
||||
Text = "Notifications"
|
||||
}
|
||||
},
|
||||
Pane.Lyrics => new UserControl
|
||||
{
|
||||
Content = new TextBlock
|
||||
{
|
||||
Content = new TextBlock
|
||||
{
|
||||
Text = "Lyrics"
|
||||
}
|
||||
};
|
||||
case Pane.None:
|
||||
return null;
|
||||
default:
|
||||
throw new Exception("????");
|
||||
}
|
||||
Text = "Lyrics"
|
||||
}
|
||||
},
|
||||
Pane.None => null,
|
||||
_ => throw new Exception("????"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -454,6 +446,36 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
set => this.RaiseAndSetIfChanged(ref auxPaneWidth, value);
|
||||
}
|
||||
|
||||
private Dock auxPaneDock = Dock.Right;
|
||||
public Dock AuxPaneDock
|
||||
{
|
||||
get => auxPaneDock;
|
||||
set => this.RaiseAndSetIfChanged(ref auxPaneDock, value);
|
||||
}
|
||||
|
||||
public void ShowAuxiliaryPane(Pane pane, int width = 235, bool openleft = false)
|
||||
{
|
||||
if (SelectedPane == pane)
|
||||
{
|
||||
HideAuxiliaryPane();
|
||||
return;
|
||||
}
|
||||
|
||||
if (SelectedPane != Pane.None)
|
||||
{
|
||||
// TODO: put something here
|
||||
}
|
||||
|
||||
if (!openleft) AuxPaneDock = Dock.Right; else AuxPaneDock = Dock.Left;
|
||||
SelectedPane = pane;
|
||||
Window.SetAuxPaneOpened(true);
|
||||
}
|
||||
public void HideAuxiliaryPane()
|
||||
{
|
||||
SelectedPane = Pane.None;
|
||||
Window.SetAuxPaneOpened(false);
|
||||
}
|
||||
|
||||
#region Library
|
||||
public async void StartThings()
|
||||
{
|
||||
|
@ -592,12 +614,12 @@ namespace FRESHMusicPlayer.ViewModels
|
|||
#region NavBar
|
||||
public void OpenSettingsCommand()
|
||||
{
|
||||
SelectedPane = Pane.Settings;
|
||||
ShowAuxiliaryPane(Pane.Settings, 335);
|
||||
}
|
||||
|
||||
public void OpenQueueManagementCommand()
|
||||
{
|
||||
SelectedPane = Pane.QueueManagement;
|
||||
ShowAuxiliaryPane(Pane.QueueManagement, 335);
|
||||
}
|
||||
|
||||
public void OpenPlaylistManagementCommand()
|
||||
|
|
|
@ -206,8 +206,22 @@
|
|||
</DockPanel>
|
||||
|
||||
|
||||
<ContentControl DockPanel.Dock="Right" Background="{DynamicResource SecondaryColor}" Content="{Binding AuxPaneContent}" Width="{Binding AuxPaneWidth}">
|
||||
<ContentControl x:Name="AuxPane" DockPanel.Dock="{Binding AuxPaneDock}" Background="{DynamicResource SecondaryColor}" Content="{Binding AuxPaneContent}" Width="{Binding AuxPaneWidth}" Margin="{Binding AuxPaneMargin}">
|
||||
<ContentControl.Styles>
|
||||
<Style Selector="ContentControl.opened">
|
||||
<Style.Animations>
|
||||
<Animation Duration="0:0:1">
|
||||
<KeyFrame Cue="0%">
|
||||
<Setter Property="Margin" Value="0, 0, -300, 0"/>
|
||||
</KeyFrame>
|
||||
<KeyFrame Cue="100%">
|
||||
<Setter Property="Margin" Value="0, 0, 100, 0"/>
|
||||
</KeyFrame>
|
||||
</Animation>
|
||||
</Style.Animations>
|
||||
</Style>
|
||||
|
||||
</ContentControl.Styles>
|
||||
</ContentControl>
|
||||
<ContentControl Content="{Binding MainContent}">
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace FRESHMusicPlayer.Views
|
|||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
DoStuff();
|
||||
//DoStuff();
|
||||
RootPanel = this.FindControl<Panel>("RootPanel");
|
||||
SetValue(DragDrop.AllowDropProperty, true);
|
||||
AddHandler(DragDrop.DragEnterEvent, (s, e) => OnDragEnter(s, e));
|
||||
|
@ -36,10 +36,14 @@ namespace FRESHMusicPlayer.Views
|
|||
|
||||
}
|
||||
|
||||
private void DoStuff()
|
||||
public void SetAuxPaneOpened(bool state)
|
||||
{
|
||||
var auxPane = this.FindControl<ContentControl>("AuxPane");
|
||||
if (state) auxPane.Classes.Add("opened");
|
||||
else auxPane.Classes.Remove("opened");
|
||||
}
|
||||
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
ViewModel?.CloseThings();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
|
@ -397,7 +397,7 @@
|
|||
<Version>1.9.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NuGet.CommandLine">
|
||||
<Version>5.7.0</Version>
|
||||
<Version>5.7.2</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
@ -429,5 +429,5 @@
|
|||
<Exec Command="nuget pack FMPBlueprintRelease.nuspec -Version %(myAssemblyInfo.Version) -Properties Configuration=Blueprint -OutputDirectory $(OutDir) -BasePath $(OutDir)" />
|
||||
<Exec Command="squirrel --releasify $(OutDir)FRESHMusicPlayerBlueprint.$([System.Version]::Parse(%(myAssemblyInfo.Version)).ToString(3)).nupkg --releaseDir=BlueprintReleases" />
|
||||
</Target>
|
||||
<Import Project="..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets" Condition="Exists('..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets')" />
|
||||
<!--<Import Project="..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets" Condition="Exists('..\packages\squirrel.windows.1.9.1\build\squirrel.windows.targets')" />-->
|
||||
</Project>
|
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
@ -89,33 +90,36 @@ namespace FRESHMusicPlayer.Forms.TagEditor
|
|||
unsavedChanges = false;
|
||||
}
|
||||
|
||||
public void SaveChanges(List<string> filePaths)
|
||||
public async Task SaveChanges(List<string> filePaths)
|
||||
{
|
||||
foreach (string path in filePaths)
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var track = new Track(path)
|
||||
foreach (string path in filePaths)
|
||||
{
|
||||
Artist = ArtistBox.Text,
|
||||
Title = TitleBox.Text,
|
||||
Album = AlbumBox.Text,
|
||||
Genre = GenreBox.Text,
|
||||
Year = Convert.ToInt32(YearBox.Text),
|
||||
AlbumArtist = AlbumArtistBox.Text,
|
||||
Composer = ComposerBox.Text,
|
||||
TrackNumber = Convert.ToInt32(TrackNumBox.Text),
|
||||
DiscNumber = Convert.ToInt32(DiscNumBox.Text),
|
||||
Lyrics = new LyricsInfo()
|
||||
};
|
||||
track.Lyrics.UnsynchronizedLyrics = UntimedLyricsBox.Text;
|
||||
track.EmbeddedPictures.Clear();
|
||||
foreach (var cover in CoverArts) track.EmbeddedPictures.Add(cover);
|
||||
track.Save();
|
||||
library?.Remove(path); // update library entry, if available
|
||||
library?.Import(path);
|
||||
}
|
||||
var track = new Track(path)
|
||||
{
|
||||
Artist = ArtistBox.Text,
|
||||
Title = TitleBox.Text,
|
||||
Album = AlbumBox.Text,
|
||||
Genre = GenreBox.Text,
|
||||
Year = Convert.ToInt32(YearBox.Text),
|
||||
AlbumArtist = AlbumArtistBox.Text,
|
||||
Composer = ComposerBox.Text,
|
||||
TrackNumber = Convert.ToInt32(TrackNumBox.Text),
|
||||
DiscNumber = Convert.ToInt32(DiscNumBox.Text),
|
||||
Lyrics = new LyricsInfo()
|
||||
};
|
||||
track.Lyrics.UnsynchronizedLyrics = UntimedLyricsBox.Text;
|
||||
track.EmbeddedPictures.Clear();
|
||||
foreach (var cover in CoverArts) track.EmbeddedPictures.Add(cover);
|
||||
track.Save();
|
||||
library?.Remove(path); // update library entry, if available
|
||||
library?.Import(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveButton()
|
||||
public async Task SaveButton()
|
||||
{
|
||||
unsavedChanges = false;
|
||||
Title = $"{string.Join(", ", Displayfilepaths)} | FRESHMusicPlayer Tag Editor";
|
||||
|
@ -129,7 +133,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor
|
|||
return;
|
||||
}
|
||||
}
|
||||
SaveChanges(FilePaths);
|
||||
await SaveChanges(FilePaths);
|
||||
}
|
||||
|
||||
public void ChangeFiles()
|
||||
|
@ -219,7 +223,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor
|
|||
if (selectedIndex <= CoverArtSelector.Items.Count) CoverArtSelector.SelectedIndex = selectedIndex;
|
||||
}
|
||||
|
||||
private void Player_SongChanged(object sender, EventArgs e)
|
||||
private async void Player_SongChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (filePathsToSaveInBackground.Count != 0)
|
||||
{
|
||||
|
@ -227,13 +231,13 @@ namespace FRESHMusicPlayer.Forms.TagEditor
|
|||
{
|
||||
if (path == player.FilePath) break; // still listening to files that can't be properly saved
|
||||
}
|
||||
SaveChanges(filePathsToSaveInBackground);
|
||||
await SaveChanges(filePathsToSaveInBackground);
|
||||
filePathsToSaveInBackground.Clear();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (unsavedChanges == true)
|
||||
{
|
||||
|
@ -241,7 +245,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor
|
|||
"FRESHMusicPlayer Tag Editor",
|
||||
MessageBoxButton.YesNoCancel,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes) SaveButton();
|
||||
if (result == MessageBoxResult.Yes) await SaveButton();
|
||||
else if (result == MessageBoxResult.Cancel)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
@ -260,7 +264,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor
|
|||
}
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e) => SaveButton();
|
||||
private async void Button_Click(object sender, RoutedEventArgs e) => await SaveButton();
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e) => ChangeFiles();
|
||||
|
||||
|
@ -284,7 +288,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor
|
|||
|
||||
private void OpenMenu_MouseDown(object sender, RoutedEventArgs e) => ChangeFiles();
|
||||
|
||||
private void SaveMenuItem(object sender, RoutedEventArgs e) => SaveButton();
|
||||
private async void SaveMenuItem(object sender, RoutedEventArgs e) => await SaveButton();
|
||||
|
||||
private void ExitMenuItem(object sender, RoutedEventArgs e) => Close();
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@
|
|||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="223"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="CoverArtBox" Margin="-64,10,5,0" VerticalAlignment="Top" Height="64" Width="64" HorizontalAlignment="Right" RenderOptions.BitmapScalingMode="HighQuality" MouseLeftButtonDown="TrackTitle_MouseLeftButtonDown" MouseRightButtonDown="TrackTitle_MouseRightButtonDown" Cursor="Hand" ToolTipOpening="CoverArtBox_ToolTipOpening" ToolTipClosing="CoverArtBox_ToolTipClosing" ToolTipService.ShowDuration="12000">
|
||||
<Image x:Name="CoverArtBox" Margin="-64,10,5,0" VerticalAlignment="Top" Height="64" Width="64" HorizontalAlignment="Right" RenderOptions.BitmapScalingMode="HighQuality" MouseLeftButtonDown="TrackTitle_MouseLeftButtonDown" ContextMenu="{StaticResource MiscContext}" Cursor="Hand" ToolTipOpening="CoverArtBox_ToolTipOpening" ToolTipClosing="CoverArtBox_ToolTipClosing" ToolTipService.ShowDuration="12000">
|
||||
<Image.ToolTip>
|
||||
<ToolTip>
|
||||
<Image x:Name="CoverArtBoxToolTip" Width="450" Height="450" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
</ToolTip>
|
||||
</Image.ToolTip>
|
||||
</Image>
|
||||
<TextBlock x:Name="TitleLabel" HorizontalAlignment="Stretch" Margin="5,5,40,0" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_NOTHINGPLAYING}" VerticalAlignment="Top" FontWeight="Bold" FontSize="22" Grid.Column="1" Height="30" Foreground="{StaticResource PrimaryTextColor}" TextTrimming="CharacterEllipsis" MouseLeftButtonDown="TrackTitle_MouseLeftButtonDown" MouseRightButtonDown="TrackTitle_MouseRightButtonDown" Cursor="Hand" Grid.ColumnSpan="2" Panel.ZIndex="0"/>
|
||||
<TextBlock x:Name="TitleLabel" HorizontalAlignment="Stretch" Margin="5,5,40,0" TextWrapping="NoWrap" Text="{x:Static resx:Resources.MAINWINDOW_NOTHINGPLAYING}" VerticalAlignment="Top" FontWeight="Bold" FontSize="22" Grid.Column="1" Height="30" Foreground="{StaticResource PrimaryTextColor}" TextTrimming="CharacterEllipsis" MouseLeftButtonDown="TrackTitle_MouseLeftButtonDown" ContextMenu="{StaticResource MiscContext}" Cursor="Hand" Grid.ColumnSpan="2" Panel.ZIndex="0"/>
|
||||
<Slider x:Name="ProgressBar" Grid.Column="1" HorizontalAlignment="Stretch" Margin="37,54,45,0" VerticalAlignment="Top" Height="21" Style="{StaticResource Progress_Slider}" Value="9.8" Thumb.DragStarted="ProgressBar_DragStarted" Thumb.DragCompleted="ProgressBar_DragCompleted" ValueChanged="ProgressBar_ValueChanged" IsMoveToPointEnabled="True" MouseLeftButtonUp="ProgressBar_MouseLeftButtonUp" Cursor="Hand"/>
|
||||
<TextBlock x:Name="ProgressIndicator1" Grid.Column="1" Margin="5,56,0,0" TextWrapping="NoWrap" Text="10:00" Foreground="{StaticResource SecondaryTextColor}" Height="15" VerticalAlignment="Top" HorizontalAlignment="Left" Width="28"/>
|
||||
<TextBlock x:Name="ProgressIndicator2" Grid.Column="1" Margin="0,0,0,13" TextWrapping="NoWrap" Text="10:00" Foreground="{StaticResource SecondaryTextColor}" Height="15" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="40" MouseLeftButtonDown="ProgressIndicator2_MouseLeftButtonDown"/>
|
||||
|
|
|
@ -1,28 +1,13 @@
|
|||
using FRESHMusicPlayer.Backends;
|
||||
using FRESHMusicPlayer.Forms;
|
||||
using FRESHMusicPlayer.Forms.Playlists;
|
||||
using FRESHMusicPlayer.Forms.TagEditor;
|
||||
using FRESHMusicPlayer.Handlers;
|
||||
using FRESHMusicPlayer.Handlers.Configuration;
|
||||
using FRESHMusicPlayer.Handlers.Integrations;
|
||||
using FRESHMusicPlayer.Handlers.Notifications;
|
||||
using FRESHMusicPlayer.Pages;
|
||||
using FRESHMusicPlayer.Pages.Library;
|
||||
using FRESHMusicPlayer.Pages.Lyrics;
|
||||
using FRESHMusicPlayer.Utilities;
|
||||
using LiteDB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
namespace FRESHMusicPlayer
|
||||
|
|
|
@ -74,12 +74,6 @@ namespace FRESHMusicPlayer
|
|||
ProgressTimer.Start(); // resync the progress timer
|
||||
}
|
||||
private void TrackTitle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) => ShowAuxilliaryPane(Pane.TrackInfo, 235, true);
|
||||
private void TrackTitle_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var cm = FindResource("MiscContext") as ContextMenu;
|
||||
cm.PlacementTarget = sender as Button;
|
||||
cm.IsOpen = true;
|
||||
}
|
||||
private void TrackContextTagEditor_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var tracks = new List<string>();
|
||||
|
|
|
@ -170,7 +170,7 @@ namespace FRESHMusicPlayer
|
|||
PauseAfterCurrentTrack = false;
|
||||
}
|
||||
|
||||
LoggingHandler.Log("Changing tracks");
|
||||
LoggingHandler.Log("Changing tracks!");
|
||||
}
|
||||
private async void Player_SongException(object sender, PlaybackExceptionEventArgs e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue