using Herse.Models; using KaraokePlayer.Classes; using System; using System.Drawing; using System.Windows.Forms; namespace KaraokePlayer { public partial class SongInfoForm : Form { public SongInfoForm() { InitializeComponent(); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; this.ShowInTaskbar = false; this.TopMost = true; // Calculate dynamic positioning after form is loaded this.Load += SongInfoForm_Load; } private void SongInfoForm_Load(object sender, EventArgs e) { CalculateDynamicPositions(); } private void CalculateDynamicPositions() { // Get the actual screen dimensions int screenHeight = this.ClientSize.Height; int screenWidth = this.ClientSize.Width; // Calculate font scaling factor based on screen size // Base scaling on the smaller dimension to ensure everything fits float baseScale = Math.Min(screenHeight / 800f, screenWidth / 1200f); float fontScale = Math.Max(0.8f, Math.Min(2.0f, baseScale)); // Limit scale between 0.8x and 2.0x // Calculate spacing between labels (increases with font size) int labelSpacing = (int)(30 * fontScale); // Update font sizes upNextLabel.Font = new Font("Segoe UI", 24 * fontScale, FontStyle.Regular); singerLabel.Font = new Font("Segoe UI", 42 * fontScale, FontStyle.Bold); artistLabel.Font = new Font("Segoe UI", 36 * fontScale, FontStyle.Regular); songTitleLabel.Font = new Font("Segoe UI", 48 * fontScale, FontStyle.Bold); // Calculate proper label heights using font metrics using (Graphics g = this.CreateGraphics()) { // Get font metrics for each label SizeF upNextSize = g.MeasureString(upNextLabel.Text, upNextLabel.Font); SizeF singerSize = g.MeasureString(singerLabel.Text, singerLabel.Font); SizeF artistSize = g.MeasureString(artistLabel.Text, artistLabel.Font); SizeF songTitleSize = g.MeasureString(songTitleLabel.Text, songTitleLabel.Font); // Add extra padding for descenders (about 20% of font size) int descenderPadding = (int)(fontScale * 8); int totalLabelHeight = (int)(upNextSize.Height + descenderPadding) + (int)(singerSize.Height + descenderPadding) + (int)(artistSize.Height + descenderPadding) + (int)(songTitleSize.Height + descenderPadding); totalLabelHeight += (labelSpacing * 3); // Add spacing between labels // Calculate available space and top padding int availableSpace = screenHeight - totalLabelHeight; int topPadding = availableSpace / 2; // Resize labels to fit the actual text height plus descender padding upNextLabel.Size = new Size(upNextLabel.Width, (int)upNextSize.Height + descenderPadding); singerLabel.Size = new Size(singerLabel.Width, (int)singerSize.Height + descenderPadding); artistLabel.Size = new Size(artistLabel.Width, (int)artistSize.Height + descenderPadding); songTitleLabel.Size = new Size(songTitleLabel.Width, (int)songTitleSize.Height + descenderPadding); // Position labels dynamically with spacing upNextLabel.Location = new Point(upNextLabel.Location.X, topPadding); singerLabel.Location = new Point(singerLabel.Location.X, topPadding + upNextLabel.Height + labelSpacing); artistLabel.Location = new Point(artistLabel.Location.X, topPadding + upNextLabel.Height + labelSpacing + singerLabel.Height + labelSpacing); songTitleLabel.Location = new Point(songTitleLabel.Location.X, topPadding + upNextLabel.Height + labelSpacing + singerLabel.Height + labelSpacing + artistLabel.Height + labelSpacing); } } public void Update(QueueItem queueItem) { if (queueItem?.Singer != null) { singerLabel.Text = queueItem.Singer.Name; } if (queueItem?.Song != null) { artistLabel.Text = queueItem.Song.Artist; songTitleLabel.Text = queueItem.Song.Title; } // Recalculate positioning after text changes to ensure proper sizing CalculateDynamicPositions(); } } }