Work done so far

This commit is contained in:
minster586
2026-08-11 22:42:01 -04:00
parent da5fb64400
commit 02bd8ffd5e
10 changed files with 1321 additions and 256 deletions
+93 -8
View File
@@ -30,6 +30,26 @@ namespace PainoBar_Helper
InitializeEvents();
UpdateProfilesMenu();
UpdateConnectionStatus(ConnectionStatus.Disconnected);
// Set initial status
if (statusLabelRight != null)
{
var activeProfile = _profileManager.GetActiveProfile();
if (activeProfile != null)
{
statusLabelRight.Text = $"Ready - Profile: {activeProfile.Name}";
}
else if (_profileManager.Profiles.Any())
{
// If no active profile but profiles exist, set the first one as active
_profileManager.SetActiveProfile(_profileManager.Profiles.First().Name);
statusLabelRight.Text = $"Ready - Profile: {_profileManager.ActiveProfileName}";
}
else
{
statusLabelRight.Text = "Ready - No profile configured";
}
}
}
#region Initialization
@@ -83,18 +103,58 @@ namespace PainoBar_Helper
return;
}
// Get pianobar.exe path from active profile or use default
var activeProfile = _profileManager.GetActiveProfile();
if (activeProfile == null)
{
var result = MessageBox.Show(
"No profile selected. Would you like to create one now?\n\n" +
"Click Yes to open Settings, or No to cancel.",
"No Profile",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
menuSettings_Click(sender, e);
}
return;
}
string pianobarPath = activeProfile.Settings.PianobarPath;
string? configPath = _profileManager.GetActiveConfigPath();
string? eventFilePath = _profileManager.GetEventOutputPath();
// Debug information
string debugInfo = $"Profile: {activeProfile.Name}\n" +
$"Pianobar Path: {pianobarPath}\n" +
$"Config Path: {configPath ?? "(none)"}\n" +
$"Event File: {eventFilePath ?? "(none)"}\n" +
$"File Exists: {File.Exists(pianobarPath)}";
try
{
// Get pianobar.exe path (you may want to add a setting for this)
string pianobarPath = "pianobar.exe"; // Default, assumes it's in PATH
string? configPath = _profileManager.GetActiveConfigPath();
// Update status to show we're attempting connection
if (statusLabelRight != null)
statusLabelRight.Text = $"Starting Pianobar...";
_pianobarManager.Connect(pianobarPath, configPath);
_pianobarManager.Connect(pianobarPath, configPath, eventFilePath);
// Success message will be shown by the Connected event handler
}
catch (Exception ex)
{
MessageBox.Show($"Failed to connect to Pianobar:\n{ex.Message}", "Connection Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
// Update status to show connection failed
if (statusLabelRight != null)
statusLabelRight.Text = "Failed to start Pianobar";
MessageBox.Show(
$"Failed to start Pianobar:\n\n{ex.Message}\n\n" +
$"Debug Information:\n{debugInfo}",
"Connection Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
@@ -108,7 +168,22 @@ namespace PainoBar_Helper
return;
}
_pianobarManager.Disconnect();
if (statusLabelRight != null)
statusLabelRight.Text = "Disconnecting...";
// Check if we should kill the process or just detach
var activeProfile = _profileManager.GetActiveProfile();
bool killProcess = activeProfile?.Settings.KillProcessOnDisconnect ?? false;
if (killProcess)
{
_pianobarManager.DisconnectAndKill();
}
else
{
_pianobarManager.Disconnect();
}
_outputManager?.Stop();
}
@@ -180,7 +255,17 @@ namespace PainoBar_Helper
var settingsForm = new SettingsForm(_profileManager, activeProfile?.Settings ?? new ProfileSettings());
if (settingsForm.ShowDialog(this) == DialogResult.OK)
{
// Settings were saved, restart output manager if connected
// Settings were saved, update the UI
UpdateProfilesMenu();
// Update status to show the new active profile
var newActiveProfile = _profileManager.GetActiveProfile();
if (newActiveProfile != null && statusLabelRight != null)
{
statusLabelRight.Text = $"Profile saved: {newActiveProfile.Name}";
}
// Restart output manager if connected
if (_pianobarManager.IsConnected)
{
RestartOutputManager();