Add Reset and Detect buttons to Config dialog
- Reset button: clears custom labels, unhides all ports, removes discovered ports - Detect button: tries common VCP 60 values to discover available input ports - Version bumped to 1.1.2 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -126,4 +126,57 @@ public static class MonitorConfigManager
|
||||
{
|
||||
_cachedConfig = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save a discovered port that the monitor didn't report in its possible values.
|
||||
/// This ensures ports like DisplayPort-1 are remembered even if the monitor firmware doesn't list them.
|
||||
/// </summary>
|
||||
public static void AddDiscoveredPort(string serialNumber, string monitorName, int vcpValue, string defaultName)
|
||||
{
|
||||
var config = Load();
|
||||
var monitorConfig = config.Monitors.FirstOrDefault(m => m.SerialNumber == serialNumber);
|
||||
|
||||
if (monitorConfig == null)
|
||||
{
|
||||
monitorConfig = new MonitorConfig { SerialNumber = serialNumber, MonitorName = monitorName };
|
||||
config.Monitors.Add(monitorConfig);
|
||||
}
|
||||
|
||||
// Check if port already exists
|
||||
if (monitorConfig.Ports.Any(p => p.VcpValue == vcpValue))
|
||||
return;
|
||||
|
||||
// Add the discovered port
|
||||
monitorConfig.Ports.Add(new PortConfig
|
||||
{
|
||||
VcpValue = vcpValue,
|
||||
DefaultName = defaultName,
|
||||
CustomLabel = "",
|
||||
IsHidden = false,
|
||||
ShowInQuickSwitch = false
|
||||
});
|
||||
|
||||
Save(config);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get any discovered ports from config that the monitor didn't report.
|
||||
/// </summary>
|
||||
public static List<InputSourceOption> GetDiscoveredPorts(string serialNumber, List<InputSourceOption> reportedOptions)
|
||||
{
|
||||
var discovered = new List<InputSourceOption>();
|
||||
var monitorConfig = GetMonitorConfig(serialNumber);
|
||||
|
||||
foreach (var port in monitorConfig.Ports)
|
||||
{
|
||||
// If this port isn't in the reported options, it's a discovered port
|
||||
if (!reportedOptions.Any(o => o.Value == port.VcpValue))
|
||||
{
|
||||
var name = !string.IsNullOrWhiteSpace(port.CustomLabel) ? port.CustomLabel : port.DefaultName;
|
||||
discovered.Add(new InputSourceOption(port.VcpValue, name));
|
||||
}
|
||||
}
|
||||
|
||||
return discovered;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user