Skip to content

Commit

Permalink
Changed album, artist, and track to be drawn onto the form instead of
Browse files Browse the repository at this point in the history
using labels so as to fix the the ClearType issue when fonts are displayed
over a transparent background. See GitHub issue: #19
  • Loading branch information
aauren committed Nov 8, 2014
1 parent b1c6cec commit 39655af
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 53 deletions.
8 changes: 4 additions & 4 deletions Sources/ToastForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void toastVisibleChanged(object sender, EventArgs e)

private void timerTick(object sender, EventArgs e)
{
//Lift window by 5 pixels
//Lift window by 2 pixels
startPosY -= 2;
//If window is fully visible stop the timer
if (startPosY < Screen.PrimaryScreen.WorkingArea.Height - Height)
Expand Down Expand Up @@ -167,17 +167,17 @@ private void onOptionsClosed(object sender, EventArgs e)

public void setArtist(String text)
{
overlay.artistBox.Text = text;
overlay.setArtistText(text);
}

public void setTrack(String text)
{
overlay.trackBox.Text = text;
overlay.setTrackName(text);
}

public void setAlbum(String text)
{
overlay.albumBox.Text = text;
overlay.setAlbumnText(text);
}

public void setAlbumImageUrl(String url)
Expand Down
46 changes: 0 additions & 46 deletions Sources/ToastOverlay.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 41 additions & 3 deletions Sources/ToastOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,54 @@ namespace spotifytoaster
{
public partial class ToastOverlay : Form
{
private Options myOptions;
private String album;
private String artist;
private String trackName;

public ToastOverlay()
{
InitializeComponent();
}

internal void initializeFormSettings(Options myOptions)
{
albumBox.ForeColor = myOptions.ToastForegroundColor;
artistBox.ForeColor = myOptions.ToastForegroundColor;
trackBox.ForeColor = myOptions.ToastForegroundColor;
this.myOptions = myOptions;
}

protected override void OnPaint(PaintEventArgs e)
{
paintText(album, 80.0F, 10.0F, e);
paintText(artist, 80.0F, 34.0F, e);
paintText(trackName, 80.0F, 57.0F, e);
}

private void paintText(String text, float x, float y, PaintEventArgs e)
{
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
System.Drawing.Graphics formGraphics = this.CreateGraphics();
System.Drawing.Font drawFont = new System.Drawing.Font("Microsoft Sans Serif", 10, FontStyle.Bold);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(myOptions.ToastForegroundColor);
System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
e.Graphics.DrawString(text, drawFont, drawBrush, x, y, drawFormat);
drawFont.Dispose();
drawBrush.Dispose();
formGraphics.Dispose();
}

internal void setAlbumnText(String text)
{
album = text;
}

internal void setArtistText(String text)
{
artist = text;
}

internal void setTrackName(String text)
{
trackName = text;
}
}
}
Binary file modified bin/Release/SpotifyToaster.exe
Binary file not shown.

0 comments on commit 39655af

Please sign in to comment.