Various changes

This commit is contained in:
Royce551 2022-06-05 20:40:43 -05:00
parent 26059363ed
commit b66de328ca
7 changed files with 118 additions and 89 deletions

View file

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

View file

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

View file

@ -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();

View file

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

View file

@ -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();

View file

@ -1,33 +1,18 @@
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
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>

View file

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