diff --git a/Sources/ToastForm.cs b/Sources/ToastForm.cs index c77708d..37539db 100644 --- a/Sources/ToastForm.cs +++ b/Sources/ToastForm.cs @@ -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) @@ -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) diff --git a/Sources/ToastOverlay.Designer.cs b/Sources/ToastOverlay.Designer.cs index 16377f0..d1aed05 100644 --- a/Sources/ToastOverlay.Designer.cs +++ b/Sources/ToastOverlay.Designer.cs @@ -28,47 +28,8 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.trackBox = new System.Windows.Forms.Label(); - this.artistBox = new System.Windows.Forms.Label(); - this.albumBox = new System.Windows.Forms.Label(); this.SuspendLayout(); // - // trackBox - // - this.trackBox.AutoSize = true; - this.trackBox.BackColor = System.Drawing.Color.WhiteSmoke; - this.trackBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.trackBox.ForeColor = System.Drawing.Color.YellowGreen; - this.trackBox.Location = new System.Drawing.Point(80, 57); - this.trackBox.Name = "trackBox"; - this.trackBox.Size = new System.Drawing.Size(93, 16); - this.trackBox.TabIndex = 8; - this.trackBox.Text = "Track Name"; - // - // artistBox - // - this.artistBox.AutoSize = true; - this.artistBox.BackColor = System.Drawing.Color.WhiteSmoke; - this.artistBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.artistBox.ForeColor = System.Drawing.Color.YellowGreen; - this.artistBox.Location = new System.Drawing.Point(80, 34); - this.artistBox.Name = "artistBox"; - this.artistBox.Size = new System.Drawing.Size(43, 16); - this.artistBox.TabIndex = 7; - this.artistBox.Text = "Artist"; - // - // albumBox - // - this.albumBox.AutoSize = true; - this.albumBox.BackColor = System.Drawing.Color.WhiteSmoke; - this.albumBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.albumBox.ForeColor = System.Drawing.Color.YellowGreen; - this.albumBox.Location = new System.Drawing.Point(80, 10); - this.albumBox.Name = "albumBox"; - this.albumBox.Size = new System.Drawing.Size(51, 16); - this.albumBox.TabIndex = 12; - this.albumBox.Text = "Album"; - // // ToastOverlay // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -76,9 +37,6 @@ private void InitializeComponent() this.BackColor = System.Drawing.Color.WhiteSmoke; this.ClientSize = new System.Drawing.Size(363, 84); this.ControlBox = false; - this.Controls.Add(this.albumBox); - this.Controls.Add(this.trackBox); - this.Controls.Add(this.artistBox); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "ToastOverlay"; this.ShowIcon = false; @@ -87,15 +45,11 @@ private void InitializeComponent() this.TopMost = true; this.TransparencyKey = System.Drawing.Color.WhiteSmoke; this.ResumeLayout(false); - this.PerformLayout(); } #endregion - internal System.Windows.Forms.Label trackBox; - internal System.Windows.Forms.Label artistBox; - internal System.Windows.Forms.Label albumBox; } diff --git a/Sources/ToastOverlay.cs b/Sources/ToastOverlay.cs index 880f4e9..ff52dfb 100644 --- a/Sources/ToastOverlay.cs +++ b/Sources/ToastOverlay.cs @@ -12,6 +12,11 @@ namespace spotifytoaster { public partial class ToastOverlay : Form { + private Options myOptions; + private String album; + private String artist; + private String trackName; + public ToastOverlay() { InitializeComponent(); @@ -19,9 +24,42 @@ public ToastOverlay() 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; } } } diff --git a/bin/Release/SpotifyToaster.exe b/bin/Release/SpotifyToaster.exe index c5faf7a..acfdf63 100644 Binary files a/bin/Release/SpotifyToaster.exe and b/bin/Release/SpotifyToaster.exe differ