mirror of
https://github.com/Royce551/FRESHMusicPlayer.git
synced 2025-01-22 10:51:52 -05:00
update stuff
This commit is contained in:
parent
b2387a8c6c
commit
676f571853
3 changed files with 53 additions and 42 deletions
|
@ -88,7 +88,7 @@
|
|||
<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"/>
|
||||
<TextBlock x:Name="TitleLabel" HorizontalAlignment="Stretch" Margin="5,5,10,0" TextWrapping="NoWrap" Text="Nothing Playing" VerticalAlignment="Top" FontWeight="Bold" FontSize="22" Grid.Column="1" Height="30" Foreground="{StaticResource PrimaryTextColor}" TextTrimming="CharacterEllipsis" MouseLeftButtonDown="TrackTitle_MouseLeftButtonDown" MouseRightButtonDown="TrackTitle_MouseRightButtonDown" Cursor="Hand"/>
|
||||
<TextBlock x:Name="TitleLabel" HorizontalAlignment="Stretch" Margin="5,5,40,0" TextWrapping="NoWrap" Text="Nothing Playing" 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"/>
|
||||
<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"/>
|
||||
<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"/>
|
||||
|
@ -99,7 +99,7 @@
|
|||
<Path x:Name="NextTrackButton" Data="{StaticResource NextIcon}" Stretch="Uniform" Fill="{StaticResource PrimaryTextColor}" RenderTransformOrigin="0.5,0.5" Grid.Column="2" Margin="0,46.467,15,15" Width="20" HorizontalAlignment="Right" MouseLeftButtonDown="NextTrackButton_MouseLeftButtonDown"/>
|
||||
<Path x:Name="RepeatOneButton" Data="{StaticResource RepeatOneIcon}" Stretch="Uniform" Fill="{StaticResource PrimaryTextColor}" RenderTransformOrigin="0.5,0.5" Grid.Column="2" Margin="0,45,142.505,13" Width="26" HorizontalAlignment="Right" MouseLeftButtonDown="RepeatOneButton_MouseLeftButtonDown"/>
|
||||
<Path x:Name="PreviousTrackButton" Data="{StaticResource PreviousIcon}" Stretch="Uniform" Fill="{StaticResource PrimaryTextColor}" RenderTransformOrigin="0.5,0.5" Grid.Column="2" Margin="0,47.803,182.505,15.997" Width="25.612" HorizontalAlignment="Right" MouseLeftButtonDown="PreviousButton_MouseLeftButtonDown"/>
|
||||
<Path x:Name="VolumeIcon" Data="{StaticResource VolumeIcon}" Stretch="Uniform" Fill="{StaticResource PrimaryTextColor}" RenderTransformOrigin="0.5,0.5" Grid.Column="2" Margin="0,15,15,0" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right"/>
|
||||
<Path x:Name="VolumeIcon" Data="{StaticResource VolumeIcon}" Stretch="Uniform" Fill="{StaticResource PrimaryTextColor}" RenderTransformOrigin="0.5,0.5" Grid.Column="2" Margin="0,15,15,0" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right" Panel.ZIndex="1"/>
|
||||
|
||||
<!--Hitboxes for the above paths-->
|
||||
<Rectangle Stretch="Uniform" Fill="Transparent" RenderTransformOrigin="0.5,0.5" Grid.Column="2" Margin="0,45,143,13" Width="23" HorizontalAlignment="Right" MouseLeftButtonDown="RepeatOneButton_MouseLeftButtonDown" Cursor="Hand"/>
|
||||
|
@ -132,7 +132,7 @@
|
|||
</EventTrigger>
|
||||
</Rectangle.Triggers>
|
||||
</Rectangle>
|
||||
<Slider x:Name="VolumeBar" Grid.Column="2" Margin="0,14,43,0" Foreground="Red" BorderBrush="#FFAC0505" Height="21" VerticalAlignment="Top" HorizontalAlignment="Right" Width="104" Opacity="0" Maximum="100" ValueChanged="VolumeBar_ValueChanged" IsMoveToPointEnabled="True" Value="100" Style="{StaticResource Progress_Slider}">
|
||||
<Slider x:Name="VolumeBar" Grid.Column="2" Margin="0,14,43,0" Foreground="Red" BorderBrush="#FFAC0505" Height="21" VerticalAlignment="Top" HorizontalAlignment="Right" Width="104" Opacity="0" Maximum="100" ValueChanged="VolumeBar_ValueChanged" IsMoveToPointEnabled="True" Value="100" Style="{StaticResource Progress_Slider}" Panel.ZIndex="1">
|
||||
<Slider.Triggers>
|
||||
<EventTrigger RoutedEvent="MouseEnter">
|
||||
<BeginStoryboard>
|
||||
|
|
|
@ -62,9 +62,10 @@ namespace FRESHMusicPlayer
|
|||
public SystemMediaTransportControls Smtc;
|
||||
public PlaytimeTrackingHandler TrackingHandler;
|
||||
public bool PauseAfterCurrentTrack = false;
|
||||
|
||||
// TODO: should probably come up with a cleaner solution for this
|
||||
public Border ControlsBoxBorderProperty { get => ControlsBoxBorder; set => ControlsBoxBorder = value; }
|
||||
public Grid ControlsBoxProperty { get => ControlsBox; set => ControlsBox= value; }
|
||||
public Grid ControlsBoxProperty { get => ControlsBox; set => ControlsBox = value; }
|
||||
public DockPanel MainBarProperty { get => MainBar; set => MainBar = value; }
|
||||
public MainWindow(string[] initialFile = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace TestPlugin
|
|||
public class TestPlugin : IPlugin
|
||||
{
|
||||
public string Name { get; set; } = "Controls Box Colorfier";
|
||||
public string Description { get; set; } = "Matches the color of the controls box to the current track.";
|
||||
public string Description { get; set; } = "Matches the color of the controls box to the current track";
|
||||
public string Author { get; set; } = "Squid Grill";
|
||||
public MainWindow Window { get; set; }
|
||||
public Player Player { get; set; }
|
||||
|
@ -30,45 +30,55 @@ namespace TestPlugin
|
|||
Player.SongChanged += Player_SongChanged;
|
||||
}
|
||||
|
||||
public void Player_SongChanged(object sender, EventArgs e)
|
||||
public async void Player_SongChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (MainWindow.CurrentTrack.EmbeddedPictures.Count() == 0) return;
|
||||
if (MainWindow.CurrentTrack.Album == previousAlbum) return; // Assume that all tracks with the same album name will have the same cover art
|
||||
using (var bitmap = new Drawing.Bitmap(new MemoryStream(MainWindow.CurrentTrack.EmbeddedPictures[0].PictureData)))
|
||||
if (MainWindow.CurrentTrack.EmbeddedPictures.Count() == 0)
|
||||
{
|
||||
float red = 0;
|
||||
float green = 0;
|
||||
float blue = 0;
|
||||
int totalpixels = 0;
|
||||
for (int x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
for (int y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
Drawing.Color pixel = bitmap.GetPixel(x, y);
|
||||
red += pixel.R;
|
||||
green += pixel.G;
|
||||
blue += pixel.B;
|
||||
totalpixels++;
|
||||
}
|
||||
}
|
||||
if (App.Config.Theme == Skin.Dark)
|
||||
{
|
||||
var correctionFactor = 1 + -0.5f;
|
||||
red *= correctionFactor;
|
||||
green *= correctionFactor;
|
||||
blue *= correctionFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
red = (255 - red) * 0.1f + red;
|
||||
green = (255 - green) * 0.1f + green;
|
||||
blue = (255 - blue) * 0.1f + blue;
|
||||
}
|
||||
var color = Color.FromRgb((byte)(red / totalpixels), (byte)(green / totalpixels), (byte)(blue / totalpixels));
|
||||
|
||||
|
||||
Window.ControlsBoxBorderProperty.BorderBrush = Window.ControlsBoxProperty.Background = new SolidColorBrush(color);
|
||||
Window.ControlsBoxBorderProperty.BorderBrush = Window.ControlsBoxProperty.Background = (Brush)Window.TryFindResource("ForegroundColor");
|
||||
return;
|
||||
}
|
||||
if (MainWindow.CurrentTrack.Album == previousAlbum) return; // Assume that all tracks with the same album name will have the same cover art
|
||||
await Task.Run(() =>
|
||||
{
|
||||
using (var bitmap = new Drawing.Bitmap(new MemoryStream(MainWindow.CurrentTrack.EmbeddedPictures[0].PictureData)))
|
||||
{
|
||||
float red = 0;
|
||||
float green = 0;
|
||||
float blue = 0;
|
||||
int totalpixels = 0;
|
||||
for (int x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
for (int y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
Drawing.Color pixel = bitmap.GetPixel(x, y);
|
||||
red += pixel.R;
|
||||
green += pixel.G;
|
||||
blue += pixel.B;
|
||||
totalpixels++;
|
||||
}
|
||||
}
|
||||
if (App.Config.Theme == Skin.Dark)
|
||||
{
|
||||
var correctionFactor = 1 + -0.5f;
|
||||
red *= correctionFactor;
|
||||
green *= correctionFactor;
|
||||
blue *= correctionFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
red = (255 - red) * 0.1f + red;
|
||||
green = (255 - green) * 0.1f + green;
|
||||
blue = (255 - blue) * 0.1f + blue;
|
||||
}
|
||||
var color = Color.FromRgb((byte)(red / totalpixels), (byte)(green / totalpixels), (byte)(blue / totalpixels));
|
||||
|
||||
Window.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Window.ControlsBoxBorderProperty.BorderBrush = Window.ControlsBoxProperty.Background = new SolidColorBrush(color);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
previousAlbum = MainWindow.CurrentTrack.Album;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue