Skip to content

Commit

Permalink
Adding the Details info panel
Browse files Browse the repository at this point in the history
  • Loading branch information
arsdever committed Sep 7, 2020
1 parent 0b5f656 commit 0a650ae
Show file tree
Hide file tree
Showing 16 changed files with 343 additions and 28 deletions.
2 changes: 1 addition & 1 deletion AnimationUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;

namespace application
namespace listen2me
{
public static class AnimationUtil
{
Expand Down
2 changes: 1 addition & 1 deletion ClickEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Windows;

namespace application
namespace listen2me
{
public class ClickEventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion CustomButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Text;
using System.Windows.Forms;

namespace application
namespace listen2me
{
class CustomButton : UserControl
{
Expand Down
175 changes: 175 additions & 0 deletions Details.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Input;
using static listen2me.MediaController;

namespace listen2me
{
class Details : Form
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
return cp;
}
}
public Details()
{
InitializeComponent();
}

protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
GraphicsPath path = new GraphicsPath();
path.StartFigure();
path.AddLine(new Point(curvSize, 0), new Point(e.ClipRectangle.Width - curvSize, 0));
path.AddArc(e.ClipRectangle.Width - 1 - curvSize * 2, 0, curvSize * 2, curvSize * 2, -90f, 90f);

path.AddLine(new Point(e.ClipRectangle.Width - 1, curvSize), new Point(e.ClipRectangle.Width - 1, e.ClipRectangle.Height - curvSize - bottomLine - 1));
path.AddArc(e.ClipRectangle.Width - 1 - curvSize * 2, e.ClipRectangle.Height - curvSize * 2 - bottomLine - 1, curvSize * 2, curvSize * 2, 0f, 90f);

//path.AddLine(new Point(e.ClipRectangle.Width - curvSize - 1, e.ClipRectangle.Height - 11), new Point(curPos + arrowWide, e.ClipRectangle.Height - 11));
//path.AddLine(new Point(curPos + arrowWide, e.ClipRectangle.Height - 11), new Point(curPos, e.ClipRectangle.Height - 1));
//path.AddLine(new Point(curPos, e.ClipRectangle.Height), new Point(curPos - arrowWide - 1, e.ClipRectangle.Height - 11));
//path.AddLine(new Point(curPos - arrowWide - 1, e.ClipRectangle.Height - 11), new Point(curvSize, e.ClipRectangle.Height - 11));

path.AddLine(new Point(e.ClipRectangle.Width - 1 - curvSize, e.ClipRectangle.Height - bottomLine - 1), new Point(curvSize, e.ClipRectangle.Height - bottomLine - 1));
path.AddArc(0, e.ClipRectangle.Height - curvSize * 2 - bottomLine - 1, curvSize * 2, curvSize * 2, 90f, 90f);

path.AddLine(new Point(0, e.ClipRectangle.Height - curvSize - bottomLine - 1), new Point(0, curvSize));
path.AddArc(0, 0, curvSize * 2, curvSize * 2, 180f, 90f);
path.CloseFigure();

Pen outline = new Pen(Color.FromArgb(64, 64, 64), 2);
Brush fill = new SolidBrush(Color.FromArgb(232, 16, 16, 16));
e.Graphics.FillPath(fill, path);
e.Graphics.DrawPath(outline, path);
}

protected override void OnPaintBackground(PaintEventArgs e)
{

}

protected override void OnResize(EventArgs e)
{
this.songName.Size = new Size(this.Width - 130, this.songName.Font.Height);
this.artistName.Size = new Size(this.Width - 130, this.artistName.Font.Height);
this.albumName.Size = new Size(this.Width - 130, this.albumName.Font.Height);
base.OnResize(e);
}

public void SetMediaInfo(MediaInfo info)
{
Image img = info.Thumbnail;
int imageMin = Math.Min(img.Width, img.Height);
Bitmap newImg = ImageHelper.ResizeImage(img, (float)imageMin / (float)100);
bigThumbnail.Image = newImg;

artistName.Text = info.Artist;
albumName.Text = info.AlbumTitle;
songName.Text = info.Title;
}

public void SetThumbnail(Image img)
{
int imageMin = Math.Min(img.Width, img.Height);
Bitmap newImg = ImageHelper.ResizeImage(img, (float)imageMin / (float)100);
bigThumbnail.Image = newImg;
}

private void InitializeComponent()
{
this.bigThumbnail = new PictureBox();
this.songName = new TransparentLabel();
this.artistName = new TransparentLabel();
this.albumName = new TransparentLabel();
((System.ComponentModel.ISupportInitialize)(this.bigThumbnail)).BeginInit();
this.SuspendLayout();
//
// bigThumbnail
//
this.bigThumbnail.Location = new Point(10, 10);
this.bigThumbnail.Name = "bigThumbnail";
this.bigThumbnail.Size = new Size(100, 100);
this.bigThumbnail.TabIndex = 0;
this.bigThumbnail.TabStop = false;
//
// songName
//
this.songName.AutoSize = false;
this.songName.Location = new Point(120, 10);
this.songName.Name = "songName";
this.songName.Font = new Font("Arial", 18);
this.songName.TabIndex = 1;
this.songName.TabStop = false;
this.songName.ForeColor = Color.White;
this.songName.Text = "Song Name";
this.songName.Size = new Size(this.Width - 130, this.songName.Font.Height);
//
// songName
//
this.artistName.AutoSize = false;
this.artistName.Location = new Point(120, 15 + this.songName.Font.Height);
this.artistName.Name = "artistName";
this.artistName.Font = new Font("Arial", 11);
this.artistName.TabIndex = 1;
this.artistName.TabStop = false;
this.artistName.ForeColor = Color.White;
this.artistName.Text = "Artist Name";
this.artistName.Size = new Size(this.Width - 130, this.artistName.Font.Height);
//
// songName
//
this.albumName.AutoSize = false;
this.albumName.Location = new Point(120, 20 + this.songName.Font.Height + this.artistName.Font.Height);
this.albumName.Name = "albumName";
this.albumName.Font = new Font("Arial", 7);
this.albumName.TabIndex = 2;
this.albumName.TabStop = false;
this.albumName.ForeColor = Color.White;
this.albumName.Text = "Album Name";
this.albumName.Size = new Size(this.Width - 130, this.albumName.Font.Height);
//
// Details
//
this.ClientSize = new Size(500, 120);
this.Controls.Add(this.bigThumbnail);
this.Controls.Add(this.songName);
this.Controls.Add(this.artistName);
this.Controls.Add(this.albumName);
this.FormBorderStyle = FormBorderStyle.None;
//this.BackColor = Color.Transparent;
this.Name = "Details";
((System.ComponentModel.ISupportInitialize)(this.bigThumbnail)).EndInit();
this.ResumeLayout(false);
}
public int PointerPosition
{
get { return curPos; }
set
{
if (curPos != value)
{
curPos = value;
Refresh();
}
}
}

private PictureBox bigThumbnail;
private Label songName;
private Label artistName;
private Label albumName;
private int curPos = 50;
private int curvSize = 10;
private int arrowWide = 7;
private int bottomLine = 0;
}
}
60 changes: 60 additions & 0 deletions Details.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
2 changes: 1 addition & 1 deletion ImageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Drawing.Imaging;
using System.Text;

namespace application
namespace listen2me
{
static class ImageHelper
{
Expand Down
36 changes: 26 additions & 10 deletions Listen2MeMediaController.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using FontAwesome.Sharp;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Controls.Primitives;
using System.Windows.Forms;
using Windows.Media.Control;

namespace application
namespace listen2me
{
partial class Listen2MeMediaController : Form
{
public Listen2MeMediaController() : base()
{
__taskbar.SetAsParentOf(this);
details.Location = new Point(0, 0);//this.PointToScreen(this.Location);
details.ShowInTaskbar = false;
InitializeComponent();
}

protected override void OnResize(EventArgs e)
Expand All @@ -40,12 +41,7 @@ protected override void OnPaint(PaintEventArgs e)
base.OnPaint(e);
}

public void Initialize()
{
InitializeComponent();
}

public void InitializeComponent()
private void InitializeComponent()
{
//this.playbackProgressBar = new ProgressBar();
this.prevButton = new CustomButton();
Expand Down Expand Up @@ -118,6 +114,8 @@ public void InitializeComponent()
((ISupportInitialize)(this.multimediaCover)).EndInit();
this.ResumeLayout(false);

this.multimediaCover.MouseHover += ShowDetails;
this.multimediaCover.MouseLeave += HideDetails;
this.playPauseButton.LeftClick += OnPlayPouse;
this.prevButton.LeftClick += OnPrev;
this.nextButton.LeftClick += OnNext;
Expand Down Expand Up @@ -184,6 +182,7 @@ private void UpdateButtonsState(GlobalSystemMediaTransportControlsSessionPlaybac

private void UpdateMediaInfo(MediaController.MediaInfo newInfo)
{
this.details.SetMediaInfo(newInfo);
Image img = newInfo.Thumbnail;
if (img == null)
return;
Expand Down Expand Up @@ -279,6 +278,22 @@ private void OnVolumeChange(object obj, MouseEventArgs args)
Win32ApiHelper.VolumeDown(Handle);
}

private void ShowDetails(object obj, EventArgs args)
{
Point possibleLocation = this.PointToScreen(new Point((this.Width - details.Width) / 2, -details.Height - 5));

int posX = Math.Min(possibleLocation.X, Screen.FromPoint(possibleLocation).Bounds.Width - details.Width - 10);
possibleLocation.X = posX;

details.Show();
details.Location = possibleLocation;
}

private void HideDetails(object obj, EventArgs args)
{
details.Hide();
}

//private void ShowMusicTooltip(object obj, EventArgs args)
//{
// Form toolTipForm = new Form();
Expand Down Expand Up @@ -339,5 +354,6 @@ private void UpdateSizesAndPositions()
private bool IsAnimating = false;
private int iconSize = 12;
private string songInfo = "";
private Details details = new Details();
}
}
2 changes: 1 addition & 1 deletion MediaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Windows.Media.Control;
using Windows.Storage.Streams;

namespace application
namespace listen2me
{
using MediaControlSessionManager = GlobalSystemMediaTransportControlsSessionManager;
using MediaControlSession = GlobalSystemMediaTransportControlsSession;
Expand Down
Loading

0 comments on commit 0a650ae

Please sign in to comment.