This should be done
This commit is contained in:
@@ -28,6 +28,16 @@ namespace RadioDJViewer
|
||||
private System.Windows.Forms.Timer apiTimer;
|
||||
private string lastApiXml = null;
|
||||
|
||||
private System.Windows.Forms.Timer marqueeTimerTitle;
|
||||
private System.Windows.Forms.Timer marqueeTimerArtist;
|
||||
private System.Windows.Forms.Timer marqueeTimerAlbum;
|
||||
private int marqueeOffsetTitle = 0;
|
||||
private int marqueeOffsetArtist = 0;
|
||||
private int marqueeOffsetAlbum = 0;
|
||||
private string marqueeTextTitle = "";
|
||||
private string marqueeTextArtist = "";
|
||||
private string marqueeTextAlbum = "";
|
||||
|
||||
public Main()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -39,16 +49,18 @@ namespace RadioDJViewer
|
||||
apiTimer = new System.Windows.Forms.Timer();
|
||||
apiTimer.Interval = 3000; // 3 seconds
|
||||
apiTimer.Tick += ApiTimer_Tick;
|
||||
// Set up marquee timer for title
|
||||
marqueeTimer = new System.Windows.Forms.Timer();
|
||||
marqueeTimer.Interval = 100; // Adjust speed as needed
|
||||
marqueeTimer.Tick += MarqueeTimer_Tick;
|
||||
// Marquee timers for each label
|
||||
marqueeTimerTitle = new System.Windows.Forms.Timer();
|
||||
marqueeTimerTitle.Interval = 100; // Adjust speed as needed
|
||||
marqueeTimerTitle.Tick += MarqueeTimerTitle_Tick;
|
||||
marqueeTimerArtist = new System.Windows.Forms.Timer();
|
||||
marqueeTimerArtist.Interval = 100; // Adjust speed as needed
|
||||
marqueeTimerArtist.Tick += MarqueeTimerArtist_Tick;
|
||||
marqueeTimerAlbum = new System.Windows.Forms.Timer();
|
||||
marqueeTimerAlbum.Interval = 100; // Adjust speed as needed
|
||||
marqueeTimerAlbum.Tick += MarqueeTimerAlbum_Tick;
|
||||
}
|
||||
|
||||
private System.Windows.Forms.Timer marqueeTimer;
|
||||
private int marqueeOffset = 0;
|
||||
private string marqueeText = "";
|
||||
|
||||
private void EnsureDefaultImageExists()
|
||||
{
|
||||
if (!File.Exists(defaultImagePath))
|
||||
@@ -62,21 +74,51 @@ namespace RadioDJViewer
|
||||
}
|
||||
}
|
||||
|
||||
private void MarqueeTimer_Tick(object sender, EventArgs e)
|
||||
private void MarqueeTimerTitle_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (marqueeText.Length > 0)
|
||||
int visibleChars = 30; // Adjust for label width
|
||||
if (marqueeTextTitle.Length > visibleChars)
|
||||
{
|
||||
int visibleChars = 30; // Adjust for label width
|
||||
if (marqueeText.Length > visibleChars)
|
||||
{
|
||||
marqueeOffset = (marqueeOffset + 1) % marqueeText.Length;
|
||||
string display = marqueeText.Substring(marqueeOffset) + " " + marqueeText.Substring(0, marqueeOffset);
|
||||
label4.Text = display.Substring(0, Math.Min(visibleChars, display.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
label4.Text = marqueeText;
|
||||
}
|
||||
string scrollText = marqueeTextTitle + " |";
|
||||
marqueeOffsetTitle = (marqueeOffsetTitle + 1) % scrollText.Length;
|
||||
string display = scrollText.Substring(marqueeOffsetTitle) + " " + scrollText.Substring(0, marqueeOffsetTitle);
|
||||
label4.Text = display.Substring(0, Math.Min(visibleChars, display.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
label4.Text = marqueeTextTitle;
|
||||
}
|
||||
}
|
||||
|
||||
private void MarqueeTimerArtist_Tick(object sender, EventArgs e)
|
||||
{
|
||||
int visibleChars = 30; // Adjust for label width
|
||||
if (marqueeTextArtist.Length > visibleChars)
|
||||
{
|
||||
string scrollText = marqueeTextArtist + " |";
|
||||
marqueeOffsetArtist = (marqueeOffsetArtist + 1) % scrollText.Length;
|
||||
string display = scrollText.Substring(marqueeOffsetArtist) + " " + scrollText.Substring(0, marqueeOffsetArtist);
|
||||
label5.Text = display.Substring(0, Math.Min(visibleChars, display.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
label5.Text = marqueeTextArtist;
|
||||
}
|
||||
}
|
||||
|
||||
private void MarqueeTimerAlbum_Tick(object sender, EventArgs e)
|
||||
{
|
||||
int visibleChars = 30; // Adjust for label width
|
||||
if (marqueeTextAlbum.Length > visibleChars)
|
||||
{
|
||||
string scrollText = marqueeTextAlbum + " |";
|
||||
marqueeOffsetAlbum = (marqueeOffsetAlbum + 1) % scrollText.Length;
|
||||
string display = scrollText.Substring(marqueeOffsetAlbum) + " " + scrollText.Substring(0, marqueeOffsetAlbum);
|
||||
label6.Text = display.Substring(0, Math.Min(visibleChars, display.Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
label6.Text = marqueeTextAlbum;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,6 +322,23 @@ namespace RadioDJViewer
|
||||
}
|
||||
}
|
||||
|
||||
private void StartMarqueeTimers()
|
||||
{
|
||||
marqueeOffsetTitle = 0;
|
||||
marqueeOffsetArtist = 0;
|
||||
marqueeOffsetAlbum = 0;
|
||||
marqueeTimerTitle.Start();
|
||||
marqueeTimerArtist.Start();
|
||||
marqueeTimerAlbum.Start();
|
||||
}
|
||||
|
||||
private void StopMarqueeTimers()
|
||||
{
|
||||
marqueeTimerTitle.Stop();
|
||||
marqueeTimerArtist.Stop();
|
||||
marqueeTimerAlbum.Stop();
|
||||
}
|
||||
|
||||
private void ParseAndDisplaySongInfo(string xml)
|
||||
{
|
||||
try
|
||||
@@ -292,18 +351,17 @@ namespace RadioDJViewer
|
||||
string album = doc.SelectSingleNode("//*[translate(local-name(), 'ALBUM', 'album')='album']")?.InnerText;
|
||||
string albumArt = doc.SelectSingleNode("//*[translate(local-name(), 'ALBUMART', 'albumart')='albumart']")?.InnerText;
|
||||
|
||||
marqueeText = !string.IsNullOrWhiteSpace(title) ? title : "No title";
|
||||
marqueeOffset = 0;
|
||||
marqueeTimer.Start();
|
||||
label5.Text = !string.IsNullOrWhiteSpace(artist) ? artist : "No artist";
|
||||
label6.Text = !string.IsNullOrWhiteSpace(album) ? album : "No album";
|
||||
marqueeTextTitle = !string.IsNullOrWhiteSpace(title) ? title : "No title";
|
||||
marqueeTextArtist = !string.IsNullOrWhiteSpace(artist) ? artist : "No artist";
|
||||
marqueeTextAlbum = !string.IsNullOrWhiteSpace(album) ? album : "No album";
|
||||
StartMarqueeTimers();
|
||||
|
||||
// Write to output files
|
||||
if (!string.IsNullOrEmpty(outputFolderPath))
|
||||
{
|
||||
File.WriteAllText(Path.Combine(outputFolderPath, "title.txt"), marqueeText);
|
||||
File.WriteAllText(Path.Combine(outputFolderPath, "artist.txt"), label5.Text);
|
||||
File.WriteAllText(Path.Combine(outputFolderPath, "album.txt"), label6.Text);
|
||||
File.WriteAllText(Path.Combine(outputFolderPath, "title.txt"), marqueeTextTitle);
|
||||
File.WriteAllText(Path.Combine(outputFolderPath, "artist.txt"), marqueeTextArtist);
|
||||
File.WriteAllText(Path.Combine(outputFolderPath, "album.txt"), marqueeTextAlbum);
|
||||
}
|
||||
|
||||
// Handle album art image
|
||||
@@ -318,11 +376,10 @@ namespace RadioDJViewer
|
||||
}
|
||||
catch
|
||||
{
|
||||
marqueeText = "No title";
|
||||
marqueeOffset = 0;
|
||||
marqueeTimer.Start();
|
||||
label5.Text = "No artist";
|
||||
label6.Text = "No album";
|
||||
marqueeTextTitle = "No title";
|
||||
marqueeTextArtist = "No artist";
|
||||
marqueeTextAlbum = "No album";
|
||||
StartMarqueeTimers();
|
||||
pictureBox1.Image = null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user