2025-10-20 16:22:47 +08:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text.Json;
|
2025-11-19 15:08:00 +08:00
|
|
|
using System.Threading;
|
2025-10-20 16:22:47 +08:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
using global::PowerToys.GPOWrapper;
|
2025-11-17 18:21:46 +08:00
|
|
|
using ManagedCommon;
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
2025-10-20 16:22:47 +08:00
|
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Services;
|
2025-11-24 18:08:11 +08:00
|
|
|
using PowerDisplay.Common.Models;
|
|
|
|
|
using PowerDisplay.Common.Services;
|
2025-11-24 21:58:34 +08:00
|
|
|
using PowerDisplay.Common.Utils;
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
using PowerToys.Interop;
|
2025-10-20 16:22:47 +08:00
|
|
|
|
|
|
|
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|
|
|
|
{
|
2025-11-18 20:03:36 +08:00
|
|
|
public partial class PowerDisplayViewModel : PageViewModelBase
|
2025-10-20 16:22:47 +08:00
|
|
|
{
|
2025-11-18 20:03:36 +08:00
|
|
|
protected override string ModuleName => PowerDisplaySettings.ModuleName;
|
|
|
|
|
|
2025-10-20 16:22:47 +08:00
|
|
|
private GeneralSettings GeneralSettingsConfig { get; set; }
|
|
|
|
|
|
|
|
|
|
private ISettingsUtils SettingsUtils { get; set; }
|
|
|
|
|
|
|
|
|
|
public ButtonClickCommand LaunchEventHandler => new ButtonClickCommand(Launch);
|
|
|
|
|
|
|
|
|
|
public PowerDisplayViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<PowerDisplaySettings> powerDisplaySettingsRepository, Func<string, int> ipcMSGCallBackFunc)
|
|
|
|
|
{
|
|
|
|
|
// To obtain the general settings configurations of PowerToys Settings.
|
|
|
|
|
ArgumentNullException.ThrowIfNull(settingsRepository);
|
|
|
|
|
|
|
|
|
|
SettingsUtils = settingsUtils;
|
|
|
|
|
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
|
|
|
|
|
|
|
|
|
_settings = powerDisplaySettingsRepository.SettingsConfig;
|
|
|
|
|
|
|
|
|
|
InitializeEnabledValue();
|
|
|
|
|
|
|
|
|
|
// Initialize monitors collection using property setter for proper subscription setup
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
// Parse capabilities for each loaded monitor to ensure UI displays correctly
|
|
|
|
|
var loadedMonitors = _settings.Properties.Monitors;
|
2025-11-18 20:03:36 +08:00
|
|
|
|
|
|
|
|
Logger.LogInfo($"[Constructor] Initializing with {loadedMonitors.Count} monitors from settings");
|
|
|
|
|
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
foreach (var monitor in loadedMonitors)
|
|
|
|
|
{
|
2025-11-18 20:03:36 +08:00
|
|
|
// Parse capabilities to determine feature support
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
ParseFeatureSupportFromCapabilities(monitor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Monitors = new ObservableCollection<MonitorInfo>(loadedMonitors);
|
2025-10-20 16:22:47 +08:00
|
|
|
|
|
|
|
|
// set the callback functions value to handle outgoing IPC message.
|
|
|
|
|
SendConfigMSG = ipcMSGCallBackFunc;
|
|
|
|
|
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
// Load profiles
|
|
|
|
|
LoadProfiles();
|
|
|
|
|
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
// Listen for monitor refresh events from PowerDisplay.exe
|
2025-11-17 18:21:46 +08:00
|
|
|
NativeEventWaiter.WaitForEventLoop(
|
|
|
|
|
Constants.RefreshPowerDisplayMonitorsEvent(),
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInfo("Received refresh monitors event from PowerDisplay.exe");
|
|
|
|
|
ReloadMonitorsFromSettings();
|
2025-11-19 15:26:35 +08:00
|
|
|
});
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeEnabledValue()
|
|
|
|
|
{
|
2025-11-18 20:03:36 +08:00
|
|
|
_isEnabled = GeneralSettingsConfig.Enabled.PowerDisplay;
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
public bool IsEnabled
|
2025-10-20 16:22:47 +08:00
|
|
|
{
|
2025-11-18 20:03:36 +08:00
|
|
|
get => _isEnabled;
|
2025-10-20 16:22:47 +08:00
|
|
|
set
|
|
|
|
|
{
|
2025-11-18 20:03:36 +08:00
|
|
|
if (_isEnabled != value)
|
2025-10-20 16:22:47 +08:00
|
|
|
{
|
2025-11-18 20:03:36 +08:00
|
|
|
_isEnabled = value;
|
|
|
|
|
OnPropertyChanged(nameof(IsEnabled));
|
2025-10-20 16:22:47 +08:00
|
|
|
|
|
|
|
|
GeneralSettingsConfig.Enabled.PowerDisplay = value;
|
|
|
|
|
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
|
|
|
|
SendConfigMSG(outgoing.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool RestoreSettingsOnStartup
|
|
|
|
|
{
|
|
|
|
|
get => _settings.Properties.RestoreSettingsOnStartup;
|
|
|
|
|
set => SetSettingsProperty(_settings.Properties.RestoreSettingsOnStartup, value, v => _settings.Properties.RestoreSettingsOnStartup = v);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-27 20:57:54 +08:00
|
|
|
public bool ShowSystemTrayIcon
|
|
|
|
|
{
|
|
|
|
|
get => _settings.Properties.ShowSystemTrayIcon;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (SetSettingsProperty(_settings.Properties.ShowSystemTrayIcon, value, v => _settings.Properties.ShowSystemTrayIcon = v))
|
|
|
|
|
{
|
|
|
|
|
// Explicitly signal PowerDisplay to refresh tray icon
|
|
|
|
|
// This is needed because set_config() doesn't signal SettingsUpdatedEvent to avoid UI refresh issues
|
|
|
|
|
using var eventHandle = new System.Threading.EventWaitHandle(
|
|
|
|
|
false,
|
|
|
|
|
System.Threading.EventResetMode.AutoReset,
|
|
|
|
|
Constants.SettingsUpdatedPowerDisplayEvent());
|
|
|
|
|
eventHandle.Set();
|
|
|
|
|
Logger.LogInfo($"ShowSystemTrayIcon changed to {value}, signaled SettingsUpdatedPowerDisplayEvent");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-12 16:36:43 +08:00
|
|
|
public HotkeySettings ActivationShortcut
|
|
|
|
|
{
|
|
|
|
|
get => _settings.Properties.ActivationShortcut;
|
|
|
|
|
set => SetSettingsProperty(_settings.Properties.ActivationShortcut, value, v => _settings.Properties.ActivationShortcut = v);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-20 16:22:47 +08:00
|
|
|
public string BrightnessUpdateRate
|
|
|
|
|
{
|
|
|
|
|
get => _settings.Properties.BrightnessUpdateRate;
|
|
|
|
|
set => SetSettingsProperty(_settings.Properties.BrightnessUpdateRate, value, v => _settings.Properties.BrightnessUpdateRate = v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly List<string> _brightnessUpdateRateOptions = new List<string>
|
|
|
|
|
{
|
|
|
|
|
"never",
|
|
|
|
|
"250ms",
|
|
|
|
|
"500ms",
|
|
|
|
|
"1s",
|
|
|
|
|
"2s",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public List<string> BrightnessUpdateRateOptions => _brightnessUpdateRateOptions;
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<MonitorInfo> Monitors
|
|
|
|
|
{
|
|
|
|
|
get => _monitors;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_monitors != null)
|
|
|
|
|
{
|
|
|
|
|
_monitors.CollectionChanged -= Monitors_CollectionChanged;
|
|
|
|
|
UnsubscribeFromItemPropertyChanged(_monitors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_monitors = value;
|
|
|
|
|
|
|
|
|
|
if (_monitors != null)
|
|
|
|
|
{
|
|
|
|
|
_monitors.CollectionChanged += Monitors_CollectionChanged;
|
|
|
|
|
SubscribeToItemPropertyChanged(_monitors);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OnPropertyChanged(nameof(Monitors));
|
|
|
|
|
HasMonitors = _monitors?.Count > 0;
|
2025-11-26 19:08:01 +08:00
|
|
|
|
|
|
|
|
// Update TotalMonitorCount for dynamic DisplayName
|
|
|
|
|
UpdateTotalMonitorCount();
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasMonitors
|
|
|
|
|
{
|
|
|
|
|
get => _hasMonitors;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_hasMonitors != value)
|
|
|
|
|
{
|
|
|
|
|
_hasMonitors = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Monitors_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SubscribeToItemPropertyChanged(e.NewItems?.Cast<MonitorInfo>());
|
|
|
|
|
UnsubscribeFromItemPropertyChanged(e.OldItems?.Cast<MonitorInfo>());
|
|
|
|
|
|
|
|
|
|
HasMonitors = _monitors.Count > 0;
|
|
|
|
|
_settings.Properties.Monitors = _monitors.ToList();
|
|
|
|
|
NotifySettingsChanged();
|
2025-11-26 19:08:01 +08:00
|
|
|
|
|
|
|
|
// Update TotalMonitorCount for dynamic DisplayName
|
|
|
|
|
UpdateTotalMonitorCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Update TotalMonitorCount on all monitors for dynamic DisplayName formatting.
|
|
|
|
|
/// When multiple monitors exist, DisplayName shows "Name N" format.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void UpdateTotalMonitorCount()
|
|
|
|
|
{
|
|
|
|
|
if (_monitors == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var count = _monitors.Count;
|
|
|
|
|
foreach (var monitor in _monitors)
|
|
|
|
|
{
|
|
|
|
|
monitor.TotalMonitorCount = count;
|
|
|
|
|
}
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateMonitors(MonitorInfo[] monitors)
|
|
|
|
|
{
|
|
|
|
|
if (monitors == null)
|
|
|
|
|
{
|
|
|
|
|
Monitors = new ObservableCollection<MonitorInfo>();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create a lookup of existing monitors to preserve user settings
|
|
|
|
|
var existingMonitors = _monitors.ToDictionary(m => GetMonitorKey(m), m => m);
|
|
|
|
|
|
|
|
|
|
// Create new collection with merged settings
|
|
|
|
|
var newCollection = new ObservableCollection<MonitorInfo>();
|
|
|
|
|
foreach (var newMonitor in monitors)
|
|
|
|
|
{
|
|
|
|
|
var monitorKey = GetMonitorKey(newMonitor);
|
|
|
|
|
|
2025-11-14 13:17:55 +08:00
|
|
|
// Parse capabilities to determine feature support
|
|
|
|
|
ParseFeatureSupportFromCapabilities(newMonitor);
|
|
|
|
|
|
2025-10-20 16:22:47 +08:00
|
|
|
// Check if we have an existing monitor with the same key
|
|
|
|
|
if (existingMonitors.TryGetValue(monitorKey, out var existingMonitor))
|
|
|
|
|
{
|
|
|
|
|
// Preserve user settings from existing monitor
|
|
|
|
|
newMonitor.EnableContrast = existingMonitor.EnableContrast;
|
|
|
|
|
newMonitor.EnableVolume = existingMonitor.EnableVolume;
|
2025-11-28 00:05:48 +08:00
|
|
|
newMonitor.EnableInputSource = existingMonitor.EnableInputSource;
|
2025-10-20 16:22:47 +08:00
|
|
|
newMonitor.IsHidden = existingMonitor.IsHidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newCollection.Add(newMonitor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Replace collection - property setter handles subscription management
|
|
|
|
|
Monitors = newCollection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-11-24 21:58:34 +08:00
|
|
|
/// Generate a unique key for monitor matching based on hardware ID and internal name.
|
|
|
|
|
/// Uses shared MonitorMatchingHelper from PowerDisplay.Lib for consistency.
|
2025-10-20 16:22:47 +08:00
|
|
|
/// </summary>
|
2025-11-24 21:58:34 +08:00
|
|
|
private static string GetMonitorKey(MonitorInfo monitor)
|
2025-10-20 16:22:47 +08:00
|
|
|
{
|
2025-11-24 21:58:34 +08:00
|
|
|
// Use shared helper for consistent monitor matching logic
|
|
|
|
|
return MonitorMatchingHelper.GetMonitorKey(monitor);
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
2025-11-14 13:17:55 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Parse feature support from capabilities VcpCodes list
|
|
|
|
|
/// Sets support flags based on VCP code presence
|
2025-11-24 18:08:11 +08:00
|
|
|
/// Uses shared MonitorFeatureHelper from PowerDisplay.Lib for consistency
|
2025-11-14 13:17:55 +08:00
|
|
|
/// </summary>
|
2025-11-24 18:08:11 +08:00
|
|
|
private static void ParseFeatureSupportFromCapabilities(MonitorInfo monitor)
|
2025-11-14 13:17:55 +08:00
|
|
|
{
|
|
|
|
|
if (monitor == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-24 18:08:11 +08:00
|
|
|
// Use shared helper to parse feature support
|
|
|
|
|
var result = PowerDisplay.Common.Utils.MonitorFeatureHelper.ParseFeatureSupport(
|
|
|
|
|
monitor.VcpCodes,
|
|
|
|
|
monitor.CapabilitiesRaw);
|
2025-11-14 13:17:55 +08:00
|
|
|
|
2025-11-24 18:08:11 +08:00
|
|
|
monitor.CapabilitiesStatus = result.CapabilitiesStatus;
|
|
|
|
|
monitor.SupportsBrightness = result.SupportsBrightness;
|
|
|
|
|
monitor.SupportsContrast = result.SupportsContrast;
|
|
|
|
|
monitor.SupportsColorTemperature = result.SupportsColorTemperature;
|
|
|
|
|
monitor.SupportsVolume = result.SupportsVolume;
|
2025-11-28 00:05:48 +08:00
|
|
|
monitor.SupportsInputSource = result.SupportsInputSource;
|
2025-11-14 13:17:55 +08:00
|
|
|
}
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA1816:Dispose methods should call SuppressFinalize", Justification = "Base class PageViewModelBase.Dispose() handles GC.SuppressFinalize")]
|
|
|
|
|
public override void Dispose()
|
2025-10-20 16:22:47 +08:00
|
|
|
{
|
|
|
|
|
// Unsubscribe from monitor property changes
|
|
|
|
|
UnsubscribeFromItemPropertyChanged(_monitors);
|
|
|
|
|
|
|
|
|
|
// Unsubscribe from collection changes
|
|
|
|
|
if (_monitors != null)
|
|
|
|
|
{
|
|
|
|
|
_monitors.CollectionChanged -= Monitors_CollectionChanged;
|
|
|
|
|
}
|
2025-11-18 20:03:36 +08:00
|
|
|
|
2025-11-19 15:08:00 +08:00
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
base.Dispose();
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Subscribe to PropertyChanged events for items in the collection
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SubscribeToItemPropertyChanged(IEnumerable<MonitorInfo> items)
|
|
|
|
|
{
|
|
|
|
|
if (items != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
|
|
|
|
item.PropertyChanged += OnMonitorPropertyChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unsubscribe from PropertyChanged events for items in the collection
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void UnsubscribeFromItemPropertyChanged(IEnumerable<MonitorInfo> items)
|
|
|
|
|
{
|
|
|
|
|
if (items != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in items)
|
|
|
|
|
{
|
|
|
|
|
item.PropertyChanged -= OnMonitorPropertyChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handle PropertyChanged events from MonitorInfo objects
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void OnMonitorPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (sender is MonitorInfo monitor)
|
|
|
|
|
{
|
2025-11-24 18:08:11 +08:00
|
|
|
Logger.LogDebug($"[PowerDisplayViewModel] Monitor {monitor.Name} property {e.PropertyName} changed");
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the settings object to keep it in sync
|
|
|
|
|
_settings.Properties.Monitors = _monitors.ToList();
|
|
|
|
|
|
|
|
|
|
// Save settings when any monitor property changes
|
|
|
|
|
NotifySettingsChanged();
|
2025-11-28 00:05:48 +08:00
|
|
|
|
|
|
|
|
// For feature visibility properties, explicitly signal PowerDisplay to refresh
|
|
|
|
|
// This is needed because set_config() doesn't signal SettingsUpdatedEvent to avoid UI refresh issues
|
|
|
|
|
if (e.PropertyName == nameof(MonitorInfo.EnableContrast) ||
|
|
|
|
|
e.PropertyName == nameof(MonitorInfo.EnableVolume) ||
|
|
|
|
|
e.PropertyName == nameof(MonitorInfo.EnableInputSource) ||
|
2025-11-28 16:17:39 +08:00
|
|
|
e.PropertyName == nameof(MonitorInfo.EnableRotation) ||
|
2025-11-28 00:05:48 +08:00
|
|
|
e.PropertyName == nameof(MonitorInfo.IsHidden))
|
|
|
|
|
{
|
|
|
|
|
SignalSettingsUpdated();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Signal PowerDisplay.exe that settings have been updated and need to be applied
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SignalSettingsUpdated()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var eventHandle = new System.Threading.EventWaitHandle(
|
|
|
|
|
false,
|
|
|
|
|
System.Threading.EventResetMode.AutoReset,
|
|
|
|
|
Constants.SettingsUpdatedPowerDisplayEvent());
|
|
|
|
|
eventHandle.Set();
|
|
|
|
|
Logger.LogInfo("Signaled SettingsUpdatedPowerDisplayEvent for feature visibility change");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError($"Failed to signal SettingsUpdatedPowerDisplayEvent: {ex.Message}");
|
|
|
|
|
}
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Launch()
|
|
|
|
|
{
|
|
|
|
|
var actionMessage = new PowerDisplayActionMessage
|
|
|
|
|
{
|
|
|
|
|
Action = new PowerDisplayActionMessage.ActionData
|
|
|
|
|
{
|
|
|
|
|
PowerDisplay = new PowerDisplayActionMessage.PowerDisplayAction
|
|
|
|
|
{
|
|
|
|
|
ActionName = "Launch",
|
|
|
|
|
Value = string.Empty,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-26 19:08:01 +08:00
|
|
|
SendConfigMSG(JsonSerializer.Serialize(actionMessage, SettingsSerializationContext.Default.PowerDisplayActionMessage));
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
/// <summary>
|
2025-11-19 16:16:04 +08:00
|
|
|
/// Trigger PowerDisplay.exe to apply color temperature to a specific monitor
|
2025-11-18 20:03:36 +08:00
|
|
|
/// Called after user confirms color temperature change in Settings UI
|
|
|
|
|
/// </summary>
|
2025-11-19 16:16:04 +08:00
|
|
|
/// <param name="monitorInternalName">Internal name (ID) of the monitor</param>
|
|
|
|
|
/// <param name="colorTemperature">Color temperature value to apply</param>
|
|
|
|
|
public void ApplyColorTemperatureToMonitor(string monitorInternalName, int colorTemperature)
|
2025-11-18 20:03:36 +08:00
|
|
|
{
|
2025-11-19 16:16:04 +08:00
|
|
|
// Set the pending operation in settings
|
|
|
|
|
_settings.Properties.PendingColorTemperatureOperation = new ColorTemperatureOperation
|
|
|
|
|
{
|
|
|
|
|
MonitorId = monitorInternalName,
|
2025-11-24 21:58:34 +08:00
|
|
|
ColorTemperatureVcp = colorTemperature,
|
2025-11-19 16:16:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Save settings to persist the operation
|
|
|
|
|
SettingsUtils.SaveSettings(_settings.ToJsonString(), PowerDisplaySettings.ModuleName);
|
|
|
|
|
|
|
|
|
|
// Send IPC message to trigger PowerDisplay to process the operation
|
2025-11-18 20:03:36 +08:00
|
|
|
var actionMessage = new PowerDisplayActionMessage
|
|
|
|
|
{
|
|
|
|
|
Action = new PowerDisplayActionMessage.ActionData
|
|
|
|
|
{
|
|
|
|
|
PowerDisplay = new PowerDisplayActionMessage.PowerDisplayAction
|
|
|
|
|
{
|
|
|
|
|
ActionName = "ApplyColorTemperature",
|
|
|
|
|
Value = string.Empty,
|
2025-11-19 16:16:04 +08:00
|
|
|
MonitorId = monitorInternalName,
|
|
|
|
|
ColorTemperature = colorTemperature,
|
2025-11-18 20:03:36 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-26 19:08:01 +08:00
|
|
|
SendConfigMSG(JsonSerializer.Serialize(actionMessage, SettingsSerializationContext.Default.PowerDisplayActionMessage));
|
2025-11-18 20:03:36 +08:00
|
|
|
}
|
|
|
|
|
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Reload monitor list from settings file (called when PowerDisplay.exe signals monitor changes)
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ReloadMonitorsFromSettings()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-11-17 18:21:46 +08:00
|
|
|
Logger.LogInfo("Reloading monitors from settings file");
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
|
|
|
|
|
// Read fresh settings from file
|
|
|
|
|
var updatedSettings = SettingsUtils.GetSettingsOrDefault<PowerDisplaySettings>(PowerDisplaySettings.ModuleName);
|
|
|
|
|
var updatedMonitors = updatedSettings.Properties.Monitors;
|
|
|
|
|
|
2025-11-25 16:45:06 +08:00
|
|
|
// Check for pending color temperature operation to avoid race conditions
|
|
|
|
|
// If there's a pending operation, we should preserve the local ColorTemperatureVcp value
|
|
|
|
|
// because the Settings UI just set it and PowerDisplay hasn't processed it yet
|
|
|
|
|
var pendingColorTempOp = updatedSettings.Properties.PendingColorTemperatureOperation;
|
|
|
|
|
var pendingColorTempMonitorId = pendingColorTempOp?.MonitorId;
|
|
|
|
|
var pendingColorTempValue = pendingColorTempOp?.ColorTemperatureVcp ?? 0;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(pendingColorTempMonitorId))
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInfo($"[ReloadMonitors] Found pending color temp operation for monitor: {pendingColorTempMonitorId}, will preserve local value");
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
Logger.LogInfo($"[ReloadMonitors] Loaded {updatedMonitors.Count} monitors from settings");
|
|
|
|
|
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
// Parse capabilities for each monitor
|
|
|
|
|
foreach (var monitor in updatedMonitors)
|
|
|
|
|
{
|
|
|
|
|
ParseFeatureSupportFromCapabilities(monitor);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
// Update existing MonitorInfo objects instead of replacing the collection
|
|
|
|
|
// This preserves XAML x:Bind bindings which reference specific object instances
|
|
|
|
|
if (Monitors == null)
|
|
|
|
|
{
|
|
|
|
|
// First time initialization - create new collection
|
|
|
|
|
Monitors = new ObservableCollection<MonitorInfo>(updatedMonitors);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Create a dictionary for quick lookup by InternalName
|
|
|
|
|
var updatedMonitorsDict = updatedMonitors.ToDictionary(m => m.InternalName, m => m);
|
|
|
|
|
|
|
|
|
|
// Update existing monitors or remove ones that no longer exist
|
|
|
|
|
for (int i = Monitors.Count - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
var existingMonitor = Monitors[i];
|
|
|
|
|
if (updatedMonitorsDict.TryGetValue(existingMonitor.InternalName, out var updatedMonitor))
|
|
|
|
|
{
|
|
|
|
|
// Monitor still exists - update its properties in place
|
|
|
|
|
Logger.LogInfo($"[ReloadMonitors] Updating existing monitor: {existingMonitor.InternalName}");
|
2025-11-25 16:45:06 +08:00
|
|
|
|
|
|
|
|
// Preserve local ColorTemperatureVcp if there's a pending operation for this monitor
|
|
|
|
|
// This prevents race condition where PowerDisplay's stale data overwrites user's selection
|
|
|
|
|
if (existingMonitor.InternalName == pendingColorTempMonitorId && pendingColorTempValue > 0)
|
|
|
|
|
{
|
|
|
|
|
var preservedColorTemp = existingMonitor.ColorTemperatureVcp;
|
|
|
|
|
existingMonitor.UpdateFrom(updatedMonitor);
|
|
|
|
|
existingMonitor.ColorTemperatureVcp = preservedColorTemp;
|
|
|
|
|
Logger.LogInfo($"[ReloadMonitors] Preserved local ColorTemperatureVcp: 0x{preservedColorTemp:X2} for monitor with pending operation");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
existingMonitor.UpdateFrom(updatedMonitor);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
updatedMonitorsDict.Remove(existingMonitor.InternalName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Monitor no longer exists - remove from collection
|
|
|
|
|
Logger.LogInfo($"[ReloadMonitors] Removing monitor: {existingMonitor.InternalName}");
|
|
|
|
|
Monitors.RemoveAt(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add any new monitors that weren't in the existing collection
|
|
|
|
|
foreach (var newMonitor in updatedMonitorsDict.Values)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogInfo($"[ReloadMonitors] Adding new monitor: {newMonitor.InternalName}");
|
|
|
|
|
Monitors.Add(newMonitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
|
|
|
|
|
// Update internal settings reference
|
|
|
|
|
_settings.Properties.Monitors = updatedMonitors;
|
|
|
|
|
|
2025-11-17 18:21:46 +08:00
|
|
|
Logger.LogInfo($"Successfully reloaded {updatedMonitors.Count} monitors");
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
}
|
2025-11-17 18:21:46 +08:00
|
|
|
catch (Exception ex)
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
{
|
2025-11-17 18:21:46 +08:00
|
|
|
Logger.LogError($"Failed to reload monitors from settings: {ex.Message}");
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-20 16:22:47 +08:00
|
|
|
private Func<string, int> SendConfigMSG { get; }
|
|
|
|
|
|
2025-11-18 20:03:36 +08:00
|
|
|
private bool _isEnabled;
|
2025-10-20 16:22:47 +08:00
|
|
|
private PowerDisplaySettings _settings;
|
|
|
|
|
private ObservableCollection<MonitorInfo> _monitors;
|
|
|
|
|
private bool _hasMonitors;
|
|
|
|
|
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
// Profile-related fields
|
2025-11-20 04:40:36 +08:00
|
|
|
private ObservableCollection<PowerDisplayProfile> _profiles = new ObservableCollection<PowerDisplayProfile>();
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
/// Collection of available profiles (for button display)
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
/// </summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
public ObservableCollection<PowerDisplayProfile> Profiles
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
|
|
|
|
get => _profiles;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_profiles != value)
|
|
|
|
|
{
|
|
|
|
|
_profiles = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-20 16:22:47 +08:00
|
|
|
public void RefreshEnabledState()
|
|
|
|
|
{
|
|
|
|
|
InitializeEnabledValue();
|
2025-11-18 20:03:36 +08:00
|
|
|
OnPropertyChanged(nameof(IsEnabled));
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool SetSettingsProperty<T>(T currentValue, T newValue, Action<T> setter, [CallerMemberName] string propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
if (EqualityComparer<T>.Default.Equals(currentValue, newValue))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setter(newValue);
|
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
|
NotifySettingsChanged();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// Load profiles from disk
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void LoadProfiles()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-11-24 18:08:11 +08:00
|
|
|
var profilesData = ProfileService.LoadProfiles();
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
// Load profile objects (no Custom - it's not a profile anymore)
|
|
|
|
|
Profiles.Clear();
|
|
|
|
|
foreach (var profile in profilesData.Profiles)
|
|
|
|
|
{
|
|
|
|
|
Profiles.Add(profile);
|
|
|
|
|
}
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Loaded {Profiles.Count} profiles");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError($"Failed to load profiles: {ex.Message}");
|
2025-11-20 04:40:36 +08:00
|
|
|
Profiles.Clear();
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
/// Apply a profile to monitors
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
/// </summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
public void ApplyProfile(PowerDisplayProfile profile)
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (profile == null || !profile.IsValid())
|
|
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogWarning("Invalid profile");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Applying profile: {profile.Name}");
|
|
|
|
|
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
// Create pending operation
|
2025-11-20 04:40:36 +08:00
|
|
|
var operation = new ProfileOperation(profile.Name, profile.MonitorSettings);
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
_settings.Properties.PendingProfileOperation = operation;
|
|
|
|
|
|
|
|
|
|
// Save settings
|
|
|
|
|
NotifySettingsChanged();
|
|
|
|
|
|
|
|
|
|
// Send custom action to trigger profile application
|
|
|
|
|
SendConfigMSG(
|
|
|
|
|
string.Format(
|
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
|
"{{ \"action\": {{ \"PowerDisplay\": {{ \"action_name\": \"ApplyProfile\", \"value\": \"{0}\" }} }} }}",
|
2025-11-20 04:40:36 +08:00
|
|
|
profile.Name));
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
|
|
|
|
// Signal PowerDisplay to apply profile
|
|
|
|
|
using (var eventHandle = new System.Threading.EventWaitHandle(
|
|
|
|
|
false,
|
|
|
|
|
System.Threading.EventResetMode.AutoReset,
|
|
|
|
|
Constants.ApplyProfilePowerDisplayEvent()))
|
|
|
|
|
{
|
|
|
|
|
eventHandle.Set();
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Profile '{profile.Name}' applied successfully");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError($"Failed to apply profile: {ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
/// Create a new profile
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
/// </summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
public void CreateProfile(PowerDisplayProfile profile)
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
if (profile == null || !profile.IsValid())
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogWarning("Invalid profile");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Creating profile: {profile.Name}");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-24 23:36:25 +08:00
|
|
|
var profilesData = ProfileService.LoadProfiles();
|
2025-11-20 04:40:36 +08:00
|
|
|
profilesData.SetProfile(profile);
|
2025-11-24 23:36:25 +08:00
|
|
|
ProfileService.SaveProfiles(profilesData);
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
|
|
|
|
// Reload profile list
|
|
|
|
|
LoadProfiles();
|
|
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Profile '{profile.Name}' created successfully");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogError($"Failed to create profile: {ex.Message}");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
/// Update an existing profile
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
/// </summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
public void UpdateProfile(string oldName, PowerDisplayProfile newProfile)
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
if (newProfile == null || !newProfile.IsValid())
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogWarning("Invalid profile");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Updating profile: {oldName} -> {newProfile.Name}");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-24 23:36:25 +08:00
|
|
|
var profilesData = ProfileService.LoadProfiles();
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
// Remove old profile and add updated one
|
|
|
|
|
profilesData.RemoveProfile(oldName);
|
|
|
|
|
profilesData.SetProfile(newProfile);
|
2025-11-24 23:36:25 +08:00
|
|
|
ProfileService.SaveProfiles(profilesData);
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
// Reload profile list
|
|
|
|
|
LoadProfiles();
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Profile updated to '{newProfile.Name}' successfully");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogError($"Failed to update profile: {ex.Message}");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
/// Delete a profile
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
/// </summary>
|
2025-11-20 04:40:36 +08:00
|
|
|
public void DeleteProfile(string profileName)
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
if (string.IsNullOrEmpty(profileName))
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Deleting profile: {profileName}");
|
|
|
|
|
|
2025-11-24 23:36:25 +08:00
|
|
|
var profilesData = ProfileService.LoadProfiles();
|
2025-11-20 04:40:36 +08:00
|
|
|
profilesData.RemoveProfile(profileName);
|
2025-11-24 23:36:25 +08:00
|
|
|
ProfileService.SaveProfiles(profilesData);
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
// Reload profile list
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
LoadProfiles();
|
|
|
|
|
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogInfo($"Profile '{profileName}' deleted successfully");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2025-11-20 04:40:36 +08:00
|
|
|
Logger.LogError($"Failed to delete profile: {ex.Message}");
|
Add profile management system to PowerDisplay
Introduced a comprehensive profile management system for PowerDisplay, enabling users to create, edit, delete, and apply predefined monitor settings. Key changes include:
- Added `ProfileManager` for handling profile storage and retrieval.
- Introduced `PowerDisplayProfile`, `PowerDisplayProfiles`, and related data models for profile representation.
- Enhanced `MainViewModel` and `MonitorViewModel` to support profile application and parameter change detection.
- Created `ProfileEditorDialog` for editing and creating profiles via the UI.
- Updated `PowerDisplayViewModel` to manage profiles, including commands for adding, deleting, renaming, and saving profiles.
- Added new events (`ApplyProfileEvent`) and constants for profile application.
- Updated `PowerDisplayPage` UI to include a "Profiles" section for managing profiles.
- Added serialization support for profile-related classes.
- Updated `dllmain.cpp` and `App.xaml.cs` to handle profile-related events.
These changes improve user experience by allowing quick switching between tailored monitor configurations.
2025-11-19 17:18:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-20 16:22:47 +08:00
|
|
|
private void NotifySettingsChanged()
|
|
|
|
|
{
|
2025-11-26 19:08:01 +08:00
|
|
|
// Skip during initialization when SendConfigMSG is not yet set
|
|
|
|
|
if (SendConfigMSG == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
// Persist locally first so settings survive even if the module DLL isn't loaded yet.
|
|
|
|
|
SettingsUtils.SaveSettings(_settings.ToJsonString(), PowerDisplaySettings.ModuleName);
|
|
|
|
|
|
2025-10-20 16:22:47 +08:00
|
|
|
// Using InvariantCulture as this is an IPC message
|
Refactor PowerDisplay for dynamic monitor capabilities
Removed reliance on static `MonitorType` enumeration, replacing it with dynamic `CommunicationMethod` for better flexibility. Updated `IMonitorController` and `MonitorManager` to dynamically determine monitor control capabilities.
Refactored `Monitor` model to streamline properties and improve color temperature handling. Enhanced `MonitorViewModel` with unified methods for brightness, contrast, volume, and color temperature updates, improving UI responsiveness and hardware synchronization.
Improved settings handling by adding support for hidden monitors, preserving user preferences, and separating UI configuration from hardware parameter updates. Updated the PowerDisplay Settings UI with warnings, confirmation dialogs, and better VCP capabilities formatting.
Removed legacy IPC code in favor of event-driven settings updates. Conducted general code cleanup, improving logging, error handling, and documentation for maintainability.
2025-11-14 16:45:22 +08:00
|
|
|
// This message will be intercepted by the runner, which passes the serialized JSON to
|
|
|
|
|
// PowerDisplay Module Interface's set_config() method, which then applies it in-process.
|
2025-10-20 16:22:47 +08:00
|
|
|
SendConfigMSG(
|
|
|
|
|
string.Format(
|
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
|
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
|
|
|
|
|
PowerDisplaySettings.ModuleName,
|
2025-11-26 19:08:01 +08:00
|
|
|
_settings.ToJsonString()));
|
2025-10-20 16:22:47 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|