Almost a full running program

This commit is contained in:
minster586
2025-08-27 05:58:13 -04:00
parent 581733b758
commit c8f6f7ff95
12 changed files with 891 additions and 99 deletions

View File

@@ -32,21 +32,21 @@
this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel2 = 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.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip2 = new System.Windows.Forms.MenuStrip(); this.menuStrip2 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restAPISettingToolStripMenuItem = 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.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox(); 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.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.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
@@ -60,6 +60,7 @@
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1, this.toolStripStatusLabel1,
this.toolStripStatusLabel2, this.toolStripStatusLabel2,
this.toolStripStatusLabel4,
this.toolStripStatusLabel3}); this.toolStripStatusLabel3});
this.statusStrip1.Location = new System.Drawing.Point(0, 268); this.statusStrip1.Location = new System.Drawing.Point(0, 268);
this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Name = "statusStrip1";
@@ -80,10 +81,19 @@
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(16, 20); 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 // toolStripStatusLabel3
// //
this.toolStripStatusLabel3.Name = "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.Spring = true;
this.toolStripStatusLabel3.Text = "Song Changed Updateing"; this.toolStripStatusLabel3.Text = "Song Changed Updateing";
this.toolStripStatusLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.toolStripStatusLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -103,7 +113,6 @@
// //
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.restAPISettingToolStripMenuItem, this.restAPISettingToolStripMenuItem,
this.profileToolStripMenuItem,
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
@@ -116,23 +125,19 @@
this.restAPISettingToolStripMenuItem.Text = "Rest API Setting"; this.restAPISettingToolStripMenuItem.Text = "Rest API Setting";
this.restAPISettingToolStripMenuItem.Click += new System.EventHandler(this.restAPISettingToolStripMenuItem_Click); 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 // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
// //
// aboutToolStripMenuItem // aboutToolStripMenuItem
// //
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20); this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
this.aboutToolStripMenuItem.Text = "About"; this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
// //
// pictureBox1 // pictureBox1
// //
@@ -158,25 +163,32 @@
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Song Info"; this.groupBox1.Text = "Song Info";
// //
// label1 // label6
// //
this.label1.AutoSize = true; this.label6.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.label6.Location = new System.Drawing.Point(205, 130);
this.label1.Location = new System.Drawing.Point(23, 35); this.label6.Name = "label6";
this.label1.Name = "label1"; this.label6.Size = new System.Drawing.Size(65, 16);
this.label1.Size = new System.Drawing.Size(48, 20); this.label6.TabIndex = 5;
this.label1.TabIndex = 0; this.label6.Text = "No album";
this.label1.Text = "Title:";
// //
// label2 // label5
// //
this.label2.AutoSize = true; this.label5.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.label5.Location = new System.Drawing.Point(205, 84);
this.label2.Location = new System.Drawing.Point(23, 80); this.label5.Name = "label5";
this.label2.Name = "label2"; this.label5.Size = new System.Drawing.Size(56, 16);
this.label2.Size = new System.Drawing.Size(57, 20); this.label5.TabIndex = 4;
this.label2.TabIndex = 1; this.label5.Text = "No artist";
this.label2.Text = "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 // label3
// //
@@ -188,32 +200,25 @@
this.label3.TabIndex = 2; this.label3.TabIndex = 2;
this.label3.Text = "Album:"; this.label3.Text = "Album:";
// //
// label4 // label2
// //
this.label4.AutoSize = true; this.label2.AutoSize = true;
this.label4.Location = new System.Drawing.Point(205, 41); 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.label4.Name = "label4"; this.label2.Location = new System.Drawing.Point(23, 80);
this.label4.Size = new System.Drawing.Size(58, 16); this.label2.Name = "label2";
this.label4.TabIndex = 3; this.label2.Size = new System.Drawing.Size(57, 20);
this.label4.Text = "title-data"; this.label2.TabIndex = 1;
this.label2.Text = "Artist:";
// //
// label5 // label1
// //
this.label5.AutoSize = true; this.label1.AutoSize = true;
this.label5.Location = new System.Drawing.Point(205, 84); 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.label5.Name = "label5"; this.label1.Location = new System.Drawing.Point(23, 35);
this.label5.Size = new System.Drawing.Size(66, 16); this.label1.Name = "label1";
this.label5.TabIndex = 4; this.label1.Size = new System.Drawing.Size(48, 20);
this.label5.Text = "artist-data"; this.label1.TabIndex = 0;
// this.label1.Text = "Title:";
// 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";
// //
// button1 // button1
// //
@@ -223,6 +228,7 @@
this.button1.TabIndex = 5; this.button1.TabIndex = 5;
this.button1.Text = "Connect"; this.button1.Text = "Connect";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
// //
// button2 // button2
// //
@@ -232,6 +238,7 @@
this.button2.TabIndex = 6; this.button2.TabIndex = 6;
this.button2.Text = "Disconnect"; this.button2.Text = "Disconnect";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
// //
// Main // Main
// //
@@ -267,7 +274,6 @@
private System.Windows.Forms.MenuStrip menuStrip2; private System.Windows.Forms.MenuStrip menuStrip2;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restAPISettingToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem restAPISettingToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem profileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
@@ -280,6 +286,7 @@
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
} }
} }

View File

@@ -7,19 +7,293 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml;
using System.IO;
namespace RadioDJViewer namespace RadioDJViewer
{ {
public partial class Main : Form 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() public Main()
{ {
InitializeComponent(); 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) 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
} }
} }
} }

View File

@@ -124,7 +124,7 @@
<data name="toolStripStatusLabel2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="toolStripStatusLabel2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAAIAAAACABAMAAAAxEHz4AAAABGdBTUEAALGPC/xhBQAAAANQTFRFJn8A iVBORw0KGgoAAAANSUhEUgAAAIAAAACABAMAAAAxEHz4AAAABGdBTUEAALGPC/xhBQAAAANQTFRFJn8A
Mx1isQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAB9JREFUaN7twTEBAAAAwqD1T20IX6AAAAAAAAAAAD4D Mx1isQAAAAlwSFlzAAAOvgAADr4B6kKxwAAAAB9JREFUaN7twTEBAAAAwqD1T20IX6AAAAAAAAAAAD4D
IIAAAT2Y3yoAAAAASUVORK5CYII= IIAAAT2Y3yoAAAAASUVORK5CYII=
</value> </value>
</data> </data>

View File

@@ -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<Profile> LoadAll()
{
if (!File.Exists(jsonPath)) return new List<Profile>();
var json = File.ReadAllText(jsonPath);
return JsonConvert.DeserializeObject<List<Profile>>(json) ?? new List<Profile>();
}
private static void SaveAll(List<Profile> 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<string> 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);
}
}
}
}

View File

@@ -8,8 +8,8 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace RadioDJViewer.Properties namespace RadioDJViewer.Properties {
{ using System;
/// <summary> /// <summary>
@@ -19,31 +19,26 @@ namespace RadioDJViewer.Properties
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // 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.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources internal class Resources {
{
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() internal Resources() {
{
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager internal static global::System.Resources.ResourceManager ResourceManager {
{ get {
get if (object.ReferenceEquals(resourceMan, null)) {
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RadioDJViewer.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RadioDJViewer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
@@ -56,16 +51,33 @@ namespace RadioDJViewer.Properties
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture internal static global::System.Globalization.CultureInfo Culture {
{ get {
get
{
return resourceCulture; return resourceCulture;
} }
set set {
{
resourceCulture = value; resourceCulture = value;
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap green {
get {
object obj = ResourceManager.GetObject("green", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap red {
get {
object obj = ResourceManager.GetObject("red", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
} }
} }

View File

@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
@@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
@@ -109,9 +112,16 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="green" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\green.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="red" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\red.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

View File

@@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@@ -46,6 +49,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ProfileStorage.cs" />
<Compile Include="radiodj-restapi-template.cs"> <Compile Include="radiodj-restapi-template.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -74,7 +78,9 @@
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile> </Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -88,5 +94,11 @@
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\green.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\red.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
</packages>

View File

@@ -29,11 +29,34 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.button2 = 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.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupBox1 // groupBox1
@@ -42,11 +65,18 @@
this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1"; 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.TabIndex = 0;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "Rest API Template"; 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 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
@@ -56,16 +86,9 @@
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "URL Format:"; 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 // 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.Name = "button1";
this.button1.Size = new System.Drawing.Size(157, 23); this.button1.Size = new System.Drawing.Size(157, 23);
this.button1.TabIndex = 1; this.button1.TabIndex = 1;
@@ -74,25 +97,228 @@
// //
// button2 // 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.Name = "button2";
this.button2.Size = new System.Drawing.Size(157, 23); this.button2.Size = new System.Drawing.Size(157, 23);
this.button2.TabIndex = 2; this.button2.TabIndex = 2;
this.button2.Text = "Cancel"; this.button2.Text = "Cancel";
this.button2.UseVisualStyleBackColor = true; 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 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.button2);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Settings";
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -104,5 +330,26 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2; 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;
} }
} }

View File

@@ -7,14 +7,169 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO;
namespace RadioDJViewer namespace RadioDJViewer
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
private string outputFolderPath = string.Empty;
private string mainImagesFolderPath = string.Empty;
public Form1() public Form1()
{ {
InitializeComponent(); 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();
} }
} }
} }