diff --git a/RadioDJViewer/Main.Designer.cs b/RadioDJViewer/Main.Designer.cs index 4019fcc..900fb5f 100644 --- a/RadioDJViewer/Main.Designer.cs +++ b/RadioDJViewer/Main.Designer.cs @@ -122,13 +122,13 @@ // this.restAPISettingToolStripMenuItem.Name = "restAPISettingToolStripMenuItem"; this.restAPISettingToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.restAPISettingToolStripMenuItem.Text = "Rest API Setting"; + this.restAPISettingToolStripMenuItem.Text = "Setting"; this.restAPISettingToolStripMenuItem.Click += new System.EventHandler(this.restAPISettingToolStripMenuItem_Click); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(157, 22); this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -166,7 +166,7 @@ // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(205, 130); + this.label6.Location = new System.Drawing.Point(170, 130); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(65, 16); this.label6.TabIndex = 5; @@ -175,7 +175,7 @@ // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(205, 84); + this.label5.Location = new System.Drawing.Point(170, 83); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(56, 16); this.label5.TabIndex = 4; @@ -184,7 +184,7 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(205, 41); + this.label4.Location = new System.Drawing.Point(170, 39); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(48, 16); this.label4.TabIndex = 3; @@ -270,6 +270,7 @@ private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3; private System.Windows.Forms.MenuStrip menuStrip2; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; @@ -278,15 +279,14 @@ private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4; } } diff --git a/RadioDJViewer/Main.cs b/RadioDJViewer/Main.cs index a2fffe4..2541eb4 100644 --- a/RadioDJViewer/Main.cs +++ b/RadioDJViewer/Main.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using System.Xml; using System.IO; +using System.Resources; namespace RadioDJViewer { @@ -30,6 +31,7 @@ namespace RadioDJViewer public Main() { InitializeComponent(); + EnsureDefaultImageExists(); UpdateStatusBar(); // Auto-load profiles if profiles.json exists AutoLoadProfiles(); @@ -37,6 +39,45 @@ 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; + } + + private System.Windows.Forms.Timer marqueeTimer; + private int marqueeOffset = 0; + private string marqueeText = ""; + + private void EnsureDefaultImageExists() + { + if (!File.Exists(defaultImagePath)) + { + // Try to extract from resources + var fallbackImg = Properties.Resources.fallback; + if (fallbackImg != null) + { + fallbackImg.Save(defaultImagePath, System.Drawing.Imaging.ImageFormat.Jpeg); + } + } + } + + private void MarqueeTimer_Tick(object sender, EventArgs e) + { + if (marqueeText.Length > 0) + { + 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; + } + } } private void ApiTimer_Tick(object sender, EventArgs e) @@ -170,18 +211,32 @@ namespace RadioDJViewer { string imagePath = string.Empty; string outputImageName = loadedProfile?.OutputImageName; + bool useFallback = false; if (!string.IsNullOrEmpty(mainImagesFolderPath) && !string.IsNullOrEmpty(imageName)) { imagePath = Path.Combine(mainImagesFolderPath, imageName); - } - if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath)) - { - // Show default image if not found - if (File.Exists(defaultImagePath)) + if (!File.Exists(imagePath)) { - using (var img = Image.FromFile(defaultImagePath)) + useFallback = true; + } + } + else + { + useFallback = true; + } + if (useFallback) + { + // Use fallback PNG from resources + var fallbackImg = Properties.Resources.fallback; + if (fallbackImg != null) + { + var resized = new Bitmap(fallbackImg, pictureBox1.Size); + pictureBox1.Image = resized; + // Save fallback image to output folder as PNG + if (!string.IsNullOrEmpty(outputFolderPath) && !string.IsNullOrEmpty(outputImageName)) { - pictureBox1.Image = new Bitmap(img); + string destPath = Path.Combine(outputFolderPath, Path.ChangeExtension(outputImageName, ".png")); + resized.Save(destPath, System.Drawing.Imaging.ImageFormat.Png); } } else @@ -192,19 +247,37 @@ namespace RadioDJViewer } try { - // Display in pictureBox1 using (var img = Image.FromFile(imagePath)) { - pictureBox1.Image = new Bitmap(img); - // Copy and convert to PNG in output folder if set and output image name is set + var resized = new Bitmap(img, pictureBox1.Size); + pictureBox1.Image = resized; + // Save to output folder as PNG if (!string.IsNullOrEmpty(outputFolderPath) && !string.IsNullOrEmpty(outputImageName)) { string destPath = Path.Combine(outputFolderPath, Path.ChangeExtension(outputImageName, ".png")); - img.Save(destPath, System.Drawing.Imaging.ImageFormat.Png); + resized.Save(destPath, System.Drawing.Imaging.ImageFormat.Png); } } } - catch { /* Handle errors if needed */ } + catch + { + // If loading image fails, fallback + var fallbackImg = Properties.Resources.fallback; + if (fallbackImg != null) + { + var resized = new Bitmap(fallbackImg, pictureBox1.Size); + pictureBox1.Image = resized; + if (!string.IsNullOrEmpty(outputFolderPath) && !string.IsNullOrEmpty(outputImageName)) + { + string destPath = Path.Combine(outputFolderPath, Path.ChangeExtension(outputImageName, ".png")); + resized.Save(destPath, System.Drawing.Imaging.ImageFormat.Png); + } + } + else + { + pictureBox1.Image = null; + } + } } private void ParseAndDisplaySongInfo(string xml) @@ -219,14 +292,16 @@ namespace RadioDJViewer string album = doc.SelectSingleNode("//*[translate(local-name(), 'ALBUM', 'album')='album']")?.InnerText; string albumArt = doc.SelectSingleNode("//*[translate(local-name(), 'ALBUMART', 'albumart')='albumart']")?.InnerText; - label4.Text = !string.IsNullOrWhiteSpace(title) ? title : "No title"; + 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"; // Write to output files if (!string.IsNullOrEmpty(outputFolderPath)) { - File.WriteAllText(Path.Combine(outputFolderPath, "title.txt"), label4.Text); + 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); } @@ -243,7 +318,9 @@ namespace RadioDJViewer } catch { - label4.Text = "No title"; + marqueeText = "No title"; + marqueeOffset = 0; + marqueeTimer.Start(); label5.Text = "No artist"; label6.Text = "No album"; pictureBox1.Image = null; @@ -270,7 +347,7 @@ namespace RadioDJViewer private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - string message = $"RadioDJViewer\nVersion: {version}\nGitHub: https://github.com/yourusername/RadioDJViewer"; + string message = $"RadioDJViewer\nVersion: {version}\nGitHub: https://git.smartcraft.me/minster586/RadioDJViewer"; MessageBox.Show(message, "About RadioDJViewer", MessageBoxButtons.OK, MessageBoxIcon.Information); } diff --git a/RadioDJViewer/Main.resx b/RadioDJViewer/Main.resx index c822fe8..b617e75 100644 --- a/RadioDJViewer/Main.resx +++ b/RadioDJViewer/Main.resx @@ -124,7 +124,7 @@ iVBORw0KGgoAAAANSUhEUgAAAIAAAACABAMAAAAxEHz4AAAABGdBTUEAALGPC/xhBQAAAANQTFRFJn8A - Mx1isQAAAAlwSFlzAAAOvgAADr4B6kKxwAAAAB9JREFUaN7twTEBAAAAwqD1T20IX6AAAAAAAAAAAD4D + Mx1isQAAAAlwSFlzAAAOvAAADrwBlbxySQAAAB9JREFUaN7twTEBAAAAwqD1T20IX6AAAAAAAAAAAD4D IIAAAT2Y3yoAAAAASUVORK5CYII= diff --git a/RadioDJViewer/Properties/Resources.Designer.cs b/RadioDJViewer/Properties/Resources.Designer.cs index b2f5ce0..f66a41e 100644 --- a/RadioDJViewer/Properties/Resources.Designer.cs +++ b/RadioDJViewer/Properties/Resources.Designer.cs @@ -60,6 +60,16 @@ namespace RadioDJViewer.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap fallback { + get { + object obj = ResourceManager.GetObject("fallback", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/RadioDJViewer/Properties/Resources.resx b/RadioDJViewer/Properties/Resources.resx index a647b1d..b3f5f6c 100644 --- a/RadioDJViewer/Properties/Resources.resx +++ b/RadioDJViewer/Properties/Resources.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\fallback.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/RadioDJViewer/RadioDJViewer.csproj b/RadioDJViewer/RadioDJViewer.csproj index 06dd3a2..eb4675c 100644 --- a/RadioDJViewer/RadioDJViewer.csproj +++ b/RadioDJViewer/RadioDJViewer.csproj @@ -100,5 +100,8 @@ + + + \ No newline at end of file diff --git a/RadioDJViewer/Resources/fallback.png b/RadioDJViewer/Resources/fallback.png new file mode 100644 index 0000000..c573c6f Binary files /dev/null and b/RadioDJViewer/Resources/fallback.png differ