diff --git a/RadioDJViewer/Main.Designer.cs b/RadioDJViewer/Main.Designer.cs
index 040dc38..4019fcc 100644
--- a/RadioDJViewer/Main.Designer.cs
+++ b/RadioDJViewer/Main.Designer.cs
@@ -32,21 +32,21 @@
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip2 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restAPISettingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.profileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.statusStrip1.SuspendLayout();
@@ -60,6 +60,7 @@
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.toolStripStatusLabel2,
+ this.toolStripStatusLabel4,
this.toolStripStatusLabel3});
this.statusStrip1.Location = new System.Drawing.Point(0, 268);
this.statusStrip1.Name = "statusStrip1";
@@ -80,10 +81,19 @@
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(16, 20);
//
+ // toolStripStatusLabel4
+ //
+ this.toolStripStatusLabel4.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.toolStripStatusLabel4.Name = "toolStripStatusLabel4";
+ this.toolStripStatusLabel4.Size = new System.Drawing.Size(262, 20);
+ this.toolStripStatusLabel4.Spring = true;
+ this.toolStripStatusLabel4.Text = "Profile:";
+ this.toolStripStatusLabel4.Click += new System.EventHandler(this.toolStripStatusLabel4_Click);
+ //
// toolStripStatusLabel3
//
this.toolStripStatusLabel3.Name = "toolStripStatusLabel3";
- this.toolStripStatusLabel3.Size = new System.Drawing.Size(503, 20);
+ this.toolStripStatusLabel3.Size = new System.Drawing.Size(262, 20);
this.toolStripStatusLabel3.Spring = true;
this.toolStripStatusLabel3.Text = "Song Changed Updateing";
this.toolStripStatusLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -103,7 +113,6 @@
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.restAPISettingToolStripMenuItem,
- this.profileToolStripMenuItem,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
@@ -116,23 +125,19 @@
this.restAPISettingToolStripMenuItem.Text = "Rest API Setting";
this.restAPISettingToolStripMenuItem.Click += new System.EventHandler(this.restAPISettingToolStripMenuItem_Click);
//
- // profileToolStripMenuItem
- //
- this.profileToolStripMenuItem.Name = "profileToolStripMenuItem";
- this.profileToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
- this.profileToolStripMenuItem.Text = "Profile";
- //
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exitToolStripMenuItem.Text = "Exit";
+ this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
this.aboutToolStripMenuItem.Text = "About";
+ this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
// pictureBox1
//
@@ -158,25 +163,32 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Song Info";
//
- // label1
+ // label6
//
- this.label1.AutoSize = true;
- this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label1.Location = new System.Drawing.Point(23, 35);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(48, 20);
- this.label1.TabIndex = 0;
- this.label1.Text = "Title:";
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(205, 130);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(65, 16);
+ this.label6.TabIndex = 5;
+ this.label6.Text = "No album";
//
- // label2
+ // label5
//
- this.label2.AutoSize = true;
- this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label2.Location = new System.Drawing.Point(23, 80);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(57, 20);
- this.label2.TabIndex = 1;
- this.label2.Text = "Artist:";
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(205, 84);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(56, 16);
+ this.label5.TabIndex = 4;
+ this.label5.Text = "No artist";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(205, 41);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(48, 16);
+ this.label4.TabIndex = 3;
+ this.label4.Text = "No title";
//
// label3
//
@@ -188,32 +200,25 @@
this.label3.TabIndex = 2;
this.label3.Text = "Album:";
//
- // label4
+ // label2
//
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(205, 41);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(58, 16);
- this.label4.TabIndex = 3;
- this.label4.Text = "title-data";
+ this.label2.AutoSize = true;
+ this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label2.Location = new System.Drawing.Point(23, 80);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(57, 20);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Artist:";
//
- // label5
+ // label1
//
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(205, 84);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(66, 16);
- this.label5.TabIndex = 4;
- this.label5.Text = "artist-data";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(205, 130);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(75, 16);
- this.label6.TabIndex = 5;
- this.label6.Text = "album-data";
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(23, 35);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(48, 20);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Title:";
//
// button1
//
@@ -223,6 +228,7 @@
this.button1.TabIndex = 5;
this.button1.Text = "Connect";
this.button1.UseVisualStyleBackColor = true;
+ this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
@@ -232,6 +238,7 @@
this.button2.TabIndex = 6;
this.button2.Text = "Disconnect";
this.button2.UseVisualStyleBackColor = true;
+ this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Main
//
@@ -267,7 +274,6 @@
private System.Windows.Forms.MenuStrip menuStrip2;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restAPISettingToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem profileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.PictureBox pictureBox1;
@@ -280,6 +286,7 @@
private System.Windows.Forms.Label label3;
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 172596b..a2fffe4 100644
--- a/RadioDJViewer/Main.cs
+++ b/RadioDJViewer/Main.cs
@@ -7,19 +7,293 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using System.Xml;
+using System.IO;
namespace RadioDJViewer
{
public partial class Main : Form
{
+ private string selectedFolderPath = string.Empty;
+ private string outputFolderPath = string.Empty;
+ private bool isConnected = false;
+ private string currentProfile = "Default";
+ private string currentSongImagePath = string.Empty; // Path to the current song image
+ private string defaultImagePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "default.jpg");
+ private string mainImagesFolderPath = string.Empty; // New field for main images folder path
+ private Profile loadedProfile = null; // Field to store the loaded profile
+
+ // Timer to poll REST API
+ private System.Windows.Forms.Timer apiTimer;
+ private string lastApiXml = null;
+
public Main()
{
InitializeComponent();
+ UpdateStatusBar();
+ // Auto-load profiles if profiles.json exists
+ AutoLoadProfiles();
+ // Set up timer for polling API every 3 seconds
+ apiTimer = new System.Windows.Forms.Timer();
+ apiTimer.Interval = 3000; // 3 seconds
+ apiTimer.Tick += ApiTimer_Tick;
+ }
+
+ private void ApiTimer_Tick(object sender, EventArgs e)
+ {
+ if (isConnected)
+ {
+ _ = PollRestApi();
+ }
+ }
+
+ private async Task PollRestApi()
+ {
+ if (loadedProfile == null) return;
+ string url = loadedProfile.UrlFormat;
+ if (!string.IsNullOrWhiteSpace(url))
+ {
+ url = url.Replace("{ip}", loadedProfile.IP ?? "")
+ .Replace("{port}", loadedProfile.Port ?? "")
+ .Replace("{password}", loadedProfile.Password ?? "");
+ }
+ else
+ {
+ return;
+ }
+ try
+ {
+ var client = new System.Net.Http.HttpClient();
+ var response = await client.GetAsync(url);
+ if (response.IsSuccessStatusCode)
+ {
+ var xml = await response.Content.ReadAsStringAsync();
+ if (xml != lastApiXml)
+ {
+ lastApiXml = xml;
+ ParseAndDisplaySongInfo(xml);
+ }
+ }
+ }
+ catch { }
+ }
+
+ private void AutoLoadProfiles()
+ {
+ string profilesPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "profiles.json");
+ if (File.Exists(profilesPath))
+ {
+ var profileNames = ProfileStorage.GetProfileNames();
+ if (profileNames.Count > 0)
+ {
+ // Optionally, load the first profile by default
+ var profile = ProfileStorage.LoadProfile(profileNames[0]);
+ if (profile != null)
+ {
+ LoadProfile(profile);
+ }
+ }
+ }
+ }
+
+ private async void button1_Click(object sender, EventArgs e)
+ {
+ // Connect to REST API
+ await ConnectToRestApi();
+ if (isConnected)
+ {
+ apiTimer.Start();
+ }
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ // Disconnect
+ isConnected = false;
+ apiTimer.Stop();
+ UpdateStatusBar();
+ }
+
+ private async Task ConnectToRestApi()
+ {
+ // Use loaded profile values
+ if (loadedProfile == null)
+ {
+ MessageBox.Show("No profile loaded. Please load a profile first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ isConnected = false;
+ UpdateStatusBar();
+ return;
+ }
+ string url = loadedProfile.UrlFormat;
+ // Debug: Show the URL before and after replacement
+ string debugBefore = url;
+ if (!string.IsNullOrWhiteSpace(url))
+ {
+ url = url.Replace("{ip}", loadedProfile.IP ?? "")
+ .Replace("{port}", loadedProfile.Port ?? "")
+ .Replace("{password}", loadedProfile.Password ?? "");
+ }
+ else
+ {
+ MessageBox.Show("Profile URL format is missing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ isConnected = false;
+ UpdateStatusBar();
+ return;
+ }
+ string debugAfter = url;
+ MessageBox.Show($"Connecting to: {debugAfter}\n(Original: {debugBefore})", "Debug", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ try
+ {
+ var client = new System.Net.Http.HttpClient();
+ var response = await client.GetAsync(url);
+ if (response.IsSuccessStatusCode)
+ {
+ var xml = await response.Content.ReadAsStringAsync();
+ ParseAndDisplaySongInfo(xml);
+ isConnected = true;
+ }
+ else
+ {
+ isConnected = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"Error connecting to REST API: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ isConnected = false;
+ }
+ UpdateStatusBar();
+ }
+
+ // Call this method after parsing song info, assuming image path is available from profile or API
+ private void UpdateCurrentSongImage(string imageName)
+ {
+ string imagePath = string.Empty;
+ string outputImageName = loadedProfile?.OutputImageName;
+ 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))
+ {
+ using (var img = Image.FromFile(defaultImagePath))
+ {
+ pictureBox1.Image = new Bitmap(img);
+ }
+ }
+ else
+ {
+ pictureBox1.Image = null;
+ }
+ return;
+ }
+ 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
+ if (!string.IsNullOrEmpty(outputFolderPath) && !string.IsNullOrEmpty(outputImageName))
+ {
+ string destPath = Path.Combine(outputFolderPath, Path.ChangeExtension(outputImageName, ".png"));
+ img.Save(destPath, System.Drawing.Imaging.ImageFormat.Png);
+ }
+ }
+ }
+ catch { /* Handle errors if needed */ }
+ }
+
+ private void ParseAndDisplaySongInfo(string xml)
+ {
+ try
+ {
+ var doc = new XmlDocument();
+ doc.LoadXml(xml);
+ // Parse title, artist, album from XML (case-insensitive)
+ string title = doc.SelectSingleNode("//*[translate(local-name(), 'TITLE', 'title')='title']")?.InnerText;
+ string artist = doc.SelectSingleNode("//*[translate(local-name(), 'ARTIST', 'artist')='artist']")?.InnerText;
+ 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";
+ 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, "artist.txt"), label5.Text);
+ File.WriteAllText(Path.Combine(outputFolderPath, "album.txt"), label6.Text);
+ }
+
+ // Handle album art image
+ if (!string.IsNullOrWhiteSpace(albumArt))
+ {
+ UpdateCurrentSongImage(albumArt);
+ }
+ else
+ {
+ UpdateCurrentSongImage(null);
+ }
+ }
+ catch
+ {
+ label4.Text = "No title";
+ label5.Text = "No artist";
+ label6.Text = "No album";
+ pictureBox1.Image = null;
+ }
+ }
+
+ private void UpdateStatusBar()
+ {
+ // Status icon
+ toolStripStatusLabel2.Image = isConnected ? Properties.Resources.green : Properties.Resources.red;
+ // Profile
+ toolStripStatusLabel4.Text = $"Profile: {currentProfile}";
+ // Song update notification (example)
+ toolStripStatusLabel3.Text = isConnected ? "Connected to API" : "Disconnected";
}
private void restAPISettingToolStripMenuItem_Click(object sender, EventArgs e)
{
+ // Open settings/profile dialog
+ var settingsForm = new Form1();
+ settingsForm.ShowDialog();
+ }
+ 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";
+ MessageBox.Show(message, "About RadioDJViewer", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Application.Exit();
+ }
+
+ private void toolStripStatusLabel4_Click(object sender, EventArgs e)
+ {
+ // Profile click handler (to be implemented)
+ }
+
+ public void LoadProfile(Profile profile)
+ {
+ // Update main form fields from profile
+ currentProfile = profile.Name;
+ selectedFolderPath = profile.OutputFolder;
+ outputFolderPath = profile.OutputFolder;
+ mainImagesFolderPath = profile.MainImagesFolder; // Update new field
+ loadedProfile = profile; // Store loaded profile for REST API connection
+ UpdateStatusBar();
+ // You can add more logic to update other fields if needed
}
}
}
diff --git a/RadioDJViewer/Main.resx b/RadioDJViewer/Main.resx
index f04ec69..c822fe8 100644
--- a/RadioDJViewer/Main.resx
+++ b/RadioDJViewer/Main.resx
@@ -124,7 +124,7 @@
iVBORw0KGgoAAAANSUhEUgAAAIAAAACABAMAAAAxEHz4AAAABGdBTUEAALGPC/xhBQAAAANQTFRFJn8A
- Mx1isQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAB9JREFUaN7twTEBAAAAwqD1T20IX6AAAAAAAAAAAD4D
+ Mx1isQAAAAlwSFlzAAAOvgAADr4B6kKxwAAAAB9JREFUaN7twTEBAAAAwqD1T20IX6AAAAAAAAAAAD4D
IIAAAT2Y3yoAAAAASUVORK5CYII=
diff --git a/RadioDJViewer/ProfileStorage.cs b/RadioDJViewer/ProfileStorage.cs
new file mode 100644
index 0000000..1cd8ec5
--- /dev/null
+++ b/RadioDJViewer/ProfileStorage.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Newtonsoft.Json;
+
+namespace RadioDJViewer
+{
+ public class Profile
+ {
+ public string Name { get; set; }
+ public string IP { get; set; }
+ public string Port { get; set; }
+ public string Password { get; set; }
+ public string MainImagesFolder { get; set; }
+ public string OutputFolder { get; set; }
+ public string OutputImageName { get; set; }
+ public string UrlFormat { get; set; }
+ }
+
+ public static class ProfileStorage
+ {
+ private static string jsonPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "profiles.json");
+
+ private static List LoadAll()
+ {
+ if (!File.Exists(jsonPath)) return new List();
+ var json = File.ReadAllText(jsonPath);
+ return JsonConvert.DeserializeObject>(json) ?? new List();
+ }
+
+ private static void SaveAll(List profiles)
+ {
+ var json = JsonConvert.SerializeObject(profiles, Formatting.Indented);
+ File.WriteAllText(jsonPath, json);
+ }
+
+ public static void SaveProfile(Profile profile)
+ {
+ var profiles = LoadAll();
+ var existing = profiles.FirstOrDefault(p => p.Name == profile.Name);
+ if (existing != null)
+ profiles.Remove(existing);
+ profiles.Add(profile);
+ SaveAll(profiles);
+ }
+
+ public static Profile LoadProfile(string name)
+ {
+ var profiles = LoadAll();
+ return profiles.FirstOrDefault(p => p.Name == name);
+ }
+
+ public static List GetProfileNames()
+ {
+ var profiles = LoadAll();
+ return profiles.Select(p => p.Name).ToList();
+ }
+
+ public static void DeleteProfile(string name)
+ {
+ var profiles = LoadAll();
+ var existing = profiles.FirstOrDefault(p => p.Name == name);
+ if (existing != null)
+ {
+ profiles.Remove(existing);
+ SaveAll(profiles);
+ }
+ }
+ }
+}
diff --git a/RadioDJViewer/Properties/Resources.Designer.cs b/RadioDJViewer/Properties/Resources.Designer.cs
index 0821f2d..b2f5ce0 100644
--- a/RadioDJViewer/Properties/Resources.Designer.cs
+++ b/RadioDJViewer/Properties/Resources.Designer.cs
@@ -8,10 +8,10 @@
//
//------------------------------------------------------------------------------
-namespace RadioDJViewer.Properties
-{
-
-
+namespace RadioDJViewer.Properties {
+ using System;
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -19,53 +19,65 @@ namespace RadioDJViewer.Properties
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
///
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RadioDJViewer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap green {
+ get {
+ object obj = ResourceManager.GetObject("green", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap red {
+ get {
+ object obj = ResourceManager.GetObject("red", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
}
}
diff --git a/RadioDJViewer/Properties/Resources.resx b/RadioDJViewer/Properties/Resources.resx
index af7dbeb..a647b1d 100644
--- a/RadioDJViewer/Properties/Resources.resx
+++ b/RadioDJViewer/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,16 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Resources\green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\red.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/RadioDJViewer/RadioDJViewer.csproj b/RadioDJViewer/RadioDJViewer.csproj
index 988f8c7..06dd3a2 100644
--- a/RadioDJViewer/RadioDJViewer.csproj
+++ b/RadioDJViewer/RadioDJViewer.csproj
@@ -33,6 +33,9 @@
4
+
+ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
@@ -46,6 +49,7 @@
+
Form
@@ -74,7 +78,9 @@
True
Resources.resx
+ True
+
SettingsSingleFileGenerator
Settings.Designer.cs
@@ -88,5 +94,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RadioDJViewer/Resources/green.png b/RadioDJViewer/Resources/green.png
new file mode 100644
index 0000000..b29a5a7
Binary files /dev/null and b/RadioDJViewer/Resources/green.png differ
diff --git a/RadioDJViewer/Resources/red.png b/RadioDJViewer/Resources/red.png
new file mode 100644
index 0000000..b5d02e2
Binary files /dev/null and b/RadioDJViewer/Resources/red.png differ
diff --git a/RadioDJViewer/packages.config b/RadioDJViewer/packages.config
new file mode 100644
index 0000000..5eaa239
--- /dev/null
+++ b/RadioDJViewer/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/RadioDJViewer/radiodj-restapi-template.Designer.cs b/RadioDJViewer/radiodj-restapi-template.Designer.cs
index 05fd6d8..d9fa107 100644
--- a/RadioDJViewer/radiodj-restapi-template.Designer.cs
+++ b/RadioDJViewer/radiodj-restapi-template.Designer.cs
@@ -29,11 +29,34 @@
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.button5 = new System.Windows.Forms.Button();
+ this.textBox6 = new System.Windows.Forms.TextBox();
+ this.label11 = new System.Windows.Forms.Label();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.buttonSelectOutputFolder = new System.Windows.Forms.Button();
+ this.labelOutputFolderPath = new System.Windows.Forms.Label();
+ this.textBox5 = new System.Windows.Forms.TextBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.button4 = new System.Windows.Forms.Button();
+ this.button3 = new System.Windows.Forms.Button();
+ this.textBox4 = new System.Windows.Forms.TextBox();
+ this.label5 = new System.Windows.Forms.Label();
+ this.textBox3 = new System.Windows.Forms.TextBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.textBox2 = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.comboBox1 = new System.Windows.Forms.ComboBox();
+ this.button6 = new System.Windows.Forms.Button();
+ this.label6 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
@@ -42,11 +65,18 @@
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(425, 118);
+ this.groupBox1.Size = new System.Drawing.Size(519, 75);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Rest API Template";
//
+ // textBox1
+ //
+ this.textBox1.Location = new System.Drawing.Point(90, 30);
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(412, 20);
+ this.textBox1.TabIndex = 1;
+ //
// label1
//
this.label1.AutoSize = true;
@@ -56,16 +86,9 @@
this.label1.TabIndex = 0;
this.label1.Text = "URL Format:";
//
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(90, 30);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(314, 20);
- this.textBox1.TabIndex = 1;
- //
// button1
//
- this.button1.Location = new System.Drawing.Point(152, 146);
+ this.button1.Location = new System.Drawing.Point(12, 569);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(157, 23);
this.button1.TabIndex = 1;
@@ -74,25 +97,228 @@
//
// button2
//
- this.button2.Location = new System.Drawing.Point(152, 189);
+ this.button2.Location = new System.Drawing.Point(259, 569);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(157, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true;
//
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.label6);
+ this.groupBox2.Controls.Add(this.button6);
+ this.groupBox2.Controls.Add(this.button5);
+ this.groupBox2.Controls.Add(this.textBox6);
+ this.groupBox2.Controls.Add(this.label11);
+ this.groupBox2.Controls.Add(this.groupBox3);
+ this.groupBox2.Controls.Add(this.button4);
+ this.groupBox2.Controls.Add(this.button3);
+ this.groupBox2.Controls.Add(this.textBox4);
+ this.groupBox2.Controls.Add(this.label5);
+ this.groupBox2.Controls.Add(this.textBox3);
+ this.groupBox2.Controls.Add(this.label4);
+ this.groupBox2.Controls.Add(this.textBox2);
+ this.groupBox2.Controls.Add(this.label3);
+ this.groupBox2.Controls.Add(this.label2);
+ this.groupBox2.Controls.Add(this.comboBox1);
+ this.groupBox2.Location = new System.Drawing.Point(12, 100);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(519, 470);
+ this.groupBox2.TabIndex = 3;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Profiles";
+ //
+ // button5
+ //
+ this.button5.Location = new System.Drawing.Point(322, 419);
+ this.button5.Name = "button5";
+ this.button5.Size = new System.Drawing.Size(120, 30);
+ this.button5.TabIndex = 16;
+ this.button5.Text = "Load Profile";
+ this.button5.UseVisualStyleBackColor = true;
+ //
+ // textBox6
+ //
+ this.textBox6.Location = new System.Drawing.Point(120, 62);
+ this.textBox6.Name = "textBox6";
+ this.textBox6.Size = new System.Drawing.Size(290, 20);
+ this.textBox6.TabIndex = 15;
+ //
+ // label11
+ //
+ this.label11.AutoSize = true;
+ this.label11.Location = new System.Drawing.Point(20, 65);
+ this.label11.Name = "label11";
+ this.label11.Size = new System.Drawing.Size(67, 13);
+ this.label11.TabIndex = 14;
+ this.label11.Text = "Profile Name";
+ //
+ // groupBox3
+ //
+ this.groupBox3.Controls.Add(this.buttonSelectOutputFolder);
+ this.groupBox3.Controls.Add(this.labelOutputFolderPath);
+ this.groupBox3.Controls.Add(this.textBox5);
+ this.groupBox3.Controls.Add(this.label10);
+ this.groupBox3.Location = new System.Drawing.Point(20, 258);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Size = new System.Drawing.Size(482, 135);
+ this.groupBox3.TabIndex = 12;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "Output Setting";
+ //
+ // buttonSelectOutputFolder
+ //
+ this.buttonSelectOutputFolder.Location = new System.Drawing.Point(20, 36);
+ this.buttonSelectOutputFolder.Name = "buttonSelectOutputFolder";
+ this.buttonSelectOutputFolder.Size = new System.Drawing.Size(140, 23);
+ this.buttonSelectOutputFolder.TabIndex = 17;
+ this.buttonSelectOutputFolder.Text = "Select Output Folder";
+ this.buttonSelectOutputFolder.UseVisualStyleBackColor = true;
+ //
+ // labelOutputFolderPath
+ //
+ this.labelOutputFolderPath.AutoSize = true;
+ this.labelOutputFolderPath.Location = new System.Drawing.Point(187, 46);
+ this.labelOutputFolderPath.Name = "labelOutputFolderPath";
+ this.labelOutputFolderPath.Size = new System.Drawing.Size(93, 13);
+ this.labelOutputFolderPath.TabIndex = 16;
+ this.labelOutputFolderPath.Text = "No folder selected";
+ //
+ // textBox5
+ //
+ this.textBox5.Location = new System.Drawing.Point(72, 87);
+ this.textBox5.Name = "textBox5";
+ this.textBox5.Size = new System.Drawing.Size(350, 20);
+ this.textBox5.TabIndex = 16;
+ //
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Location = new System.Drawing.Point(157, 71);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(181, 13);
+ this.label10.TabIndex = 15;
+ this.label10.Text = "Output Image save name and loction";
+ //
+ // button4
+ //
+ this.button4.Location = new System.Drawing.Point(180, 419);
+ this.button4.Name = "button4";
+ this.button4.Size = new System.Drawing.Size(120, 30);
+ this.button4.TabIndex = 9;
+ this.button4.Text = "Remove Profile";
+ this.button4.UseVisualStyleBackColor = true;
+ //
+ // button3
+ //
+ this.button3.Location = new System.Drawing.Point(40, 419);
+ this.button3.Name = "button3";
+ this.button3.Size = new System.Drawing.Size(120, 30);
+ this.button3.TabIndex = 8;
+ this.button3.Text = "Save Profile";
+ this.button3.UseVisualStyleBackColor = true;
+ //
+ // textBox4
+ //
+ this.textBox4.Location = new System.Drawing.Point(120, 167);
+ this.textBox4.Name = "textBox4";
+ this.textBox4.Size = new System.Drawing.Size(290, 20);
+ this.textBox4.TabIndex = 7;
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(20, 170);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(53, 13);
+ this.label5.TabIndex = 6;
+ this.label5.Text = "Password";
+ //
+ // textBox3
+ //
+ this.textBox3.Location = new System.Drawing.Point(120, 132);
+ this.textBox3.Name = "textBox3";
+ this.textBox3.Size = new System.Drawing.Size(290, 20);
+ this.textBox3.TabIndex = 5;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(20, 135);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(26, 13);
+ this.label4.TabIndex = 4;
+ this.label4.Text = "Port";
+ //
+ // textBox2
+ //
+ this.textBox2.Location = new System.Drawing.Point(120, 97);
+ this.textBox2.Name = "textBox2";
+ this.textBox2.Size = new System.Drawing.Size(290, 20);
+ this.textBox2.TabIndex = 3;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(20, 100);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(57, 13);
+ this.label3.TabIndex = 2;
+ this.label3.Text = "IP address";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(20, 30);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(41, 13);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Profiles";
+ //
+ // comboBox1
+ //
+ this.comboBox1.FormattingEnabled = true;
+ this.comboBox1.Location = new System.Drawing.Point(120, 27);
+ this.comboBox1.Name = "comboBox1";
+ this.comboBox1.Size = new System.Drawing.Size(290, 21);
+ this.comboBox1.TabIndex = 0;
+ //
+ // button6
+ //
+ this.button6.Location = new System.Drawing.Point(23, 202);
+ this.button6.Name = "button6";
+ this.button6.Size = new System.Drawing.Size(140, 23);
+ this.button6.TabIndex = 18;
+ this.button6.Text = "Select Main Image Folder";
+ this.button6.UseVisualStyleBackColor = true;
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(177, 207);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(93, 13);
+ this.label6.TabIndex = 19;
+ this.label6.Text = "No folder selected";
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(449, 241);
+ this.ClientSize = new System.Drawing.Size(543, 604);
+ this.Controls.Add(this.groupBox2);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
- this.Text = "Form1";
+ this.Text = "Settings";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.groupBox3.ResumeLayout(false);
+ this.groupBox3.PerformLayout();
this.ResumeLayout(false);
}
@@ -104,5 +330,26 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.ComboBox comboBox1;
+ private System.Windows.Forms.Button button4;
+ private System.Windows.Forms.Button button3;
+ private System.Windows.Forms.TextBox textBox4;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.TextBox textBox3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.TextBox textBox2;
+ private System.Windows.Forms.GroupBox groupBox3;
+ private System.Windows.Forms.Button buttonSelectOutputFolder;
+ private System.Windows.Forms.Label labelOutputFolderPath;
+ private System.Windows.Forms.TextBox textBox5;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.Button button5;
+ private System.Windows.Forms.TextBox textBox6;
+ private System.Windows.Forms.Label label11;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Button button6;
}
}
\ No newline at end of file
diff --git a/RadioDJViewer/radiodj-restapi-template.cs b/RadioDJViewer/radiodj-restapi-template.cs
index 0ee2e79..493f7dc 100644
--- a/RadioDJViewer/radiodj-restapi-template.cs
+++ b/RadioDJViewer/radiodj-restapi-template.cs
@@ -7,14 +7,169 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using System.IO;
namespace RadioDJViewer
{
public partial class Form1 : Form
{
+ private string outputFolderPath = string.Empty;
+ private string mainImagesFolderPath = string.Empty;
+
public Form1()
{
InitializeComponent();
+ this.buttonSelectOutputFolder.Click += ButtonSelectOutputFolder_Click;
+ this.button6.Click += ButtonSelectMainImagesFolder_Click;
+ this.button3.Click += button3_Click;
+ this.button1.Click += button1_Click;
+ this.button4.Click += button4_Click;
+ this.button5.Click += button5_Click;
+ this.button2.Click += button2_Click;
+ // Populate profile list on open
+ LoadProfileList();
+ // Auto-load first profile's data into fields if available
+ LoadSelectedProfileFields();
+ this.comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged;
+ }
+
+ private void LoadProfileList()
+ {
+ comboBox1.Items.Clear();
+ var names = ProfileStorage.GetProfileNames();
+ comboBox1.Items.AddRange(names.ToArray());
+ if (comboBox1.Items.Count > 0)
+ comboBox1.SelectedIndex = 0;
+ }
+
+ private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ LoadSelectedProfileFields();
+ }
+
+ private void LoadSelectedProfileFields()
+ {
+ if (comboBox1.SelectedItem != null)
+ {
+ var profile = ProfileStorage.LoadProfile(comboBox1.SelectedItem.ToString());
+ if (profile != null)
+ {
+ textBox6.Text = profile.Name;
+ textBox2.Text = profile.IP;
+ textBox3.Text = profile.Port;
+ textBox4.Text = profile.Password;
+ outputFolderPath = profile.OutputFolder;
+ mainImagesFolderPath = profile.MainImagesFolder;
+ labelOutputFolderPath.Text = outputFolderPath;
+ label6.Text = mainImagesFolderPath;
+ textBox5.Text = profile.OutputImageName;
+ textBox1.Text = profile.UrlFormat;
+ }
+ }
+ }
+
+ private void ButtonSelectOutputFolder_Click(object sender, EventArgs e)
+ {
+ using (var dialog = new FolderBrowserDialog())
+ {
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ outputFolderPath = dialog.SelectedPath;
+ labelOutputFolderPath.Text = outputFolderPath;
+ }
+ }
+ }
+
+ private void ButtonSelectMainImagesFolder_Click(object sender, EventArgs e)
+ {
+ using (var dialog = new FolderBrowserDialog())
+ {
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ mainImagesFolderPath = dialog.SelectedPath;
+ label6.Text = mainImagesFolderPath;
+ }
+ }
+ }
+
+ private void button3_Click(object sender, EventArgs e)
+ {
+ // Save Profile (Save Profile button)
+ if (string.IsNullOrWhiteSpace(textBox6.Text))
+ {
+ MessageBox.Show("Profile name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return;
+ }
+ var profile = new Profile
+ {
+ Name = textBox6.Text,
+ IP = textBox2.Text,
+ Port = textBox3.Text,
+ Password = textBox4.Text,
+ OutputFolder = outputFolderPath,
+ MainImagesFolder = mainImagesFolderPath,
+ OutputImageName = textBox5.Text,
+ UrlFormat = textBox1.Text
+ };
+ ProfileStorage.SaveProfile(profile);
+ // Refresh profile list
+ comboBox1.Items.Clear();
+ var names = ProfileStorage.GetProfileNames();
+ comboBox1.Items.AddRange(names.ToArray());
+ MessageBox.Show("Profile saved successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+
+ private void button4_Click(object sender, EventArgs e)
+ {
+ // Remove Profile (Remove Profile button)
+ if (comboBox1.SelectedItem != null)
+ {
+ ProfileStorage.DeleteProfile(comboBox1.SelectedItem.ToString());
+ comboBox1.Items.Clear();
+ var names = ProfileStorage.GetProfileNames();
+ comboBox1.Items.AddRange(names.ToArray());
+ }
+ }
+
+ private void button5_Click(object sender, EventArgs e)
+ {
+ // Load Profile (Load Profile button)
+ if (comboBox1.SelectedItem != null)
+ {
+ var profile = ProfileStorage.LoadProfile(comboBox1.SelectedItem.ToString());
+ if (profile != null)
+ {
+ textBox6.Text = profile.Name;
+ textBox2.Text = profile.IP;
+ textBox3.Text = profile.Port;
+ textBox4.Text = profile.Password;
+ outputFolderPath = profile.OutputFolder;
+ mainImagesFolderPath = profile.MainImagesFolder;
+ labelOutputFolderPath.Text = outputFolderPath;
+ label6.Text = mainImagesFolderPath;
+ textBox5.Text = profile.OutputImageName;
+ textBox1.Text = profile.UrlFormat;
+ Main mainForm = Application.OpenForms["Main"] as Main;
+ if (mainForm != null)
+ {
+ mainForm.LoadProfile(profile);
+ }
+ }
+ }
+ }
+
+ private void button1_Click(object sender, EventArgs e)
+ {
+ // Save (bottom Save button) - save all fields to the currently selected or new profile
+ button3_Click(sender, e); // Reuse Save Profile logic
+ if (!string.IsNullOrWhiteSpace(textBox6.Text))
+ this.Close();
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ // Cancel (bottom Cancel button) - close the settings window without saving
+ this.Close();
}
}
}