Files
ThreadPilot/Services/IProcessPowerPlanAssociationService.cs
T
PrimeBuild-pc 1ab85b21bd Release 1.1.1: installer, elevation & onboarding
Bump release to v1.1.1 and add release/build packaging, installer and onboarding enhancements. Key changes:

- Version bump across csproj, README and release assets to 1.1.1.
- CI/workflow: copy bundled Powerplans into single-file output, install Inno Setup, build Inno Setup installer, include installer artifacts in GitHub release, and stage unified package zips with uninstall/license files.
- Installer: update InstallScript (setup.iss) to point to staged artifacts, include Powerplans folder, and output installer to artifacts/release/installer.
- App startup/elevation: requireAdministrator manifest and App.xaml.cs now requests elevation early, terminating non-elevated instance when elevation is requested/declined.
- UX: add Performance first-run onboarding overlay (modal with blurred background), updated loading overlay visuals, and related MainWindow logic to show/hide intro and persist seen state.
- Settings & config: implement export/import configuration bundle (JSON) with Save/Open dialogs, add ReplaceConfigurationAsync and CloneConfiguration in association service, and adjust settings view labels.
- Power plan features: add PowerPlanService.AddCustomPowerPlanFileAsync and UI/command to add .pow files; adjust Import/Apply button labels.
- Performance tweaks: reduce power plan change delay from 1000ms to 250ms in config, models and viewmodels.
- Theme detection: improve ThemeService to resolve registry values and fallback to system theme helper.
- Misc: various logging/status improvements, packaging script fixes (build-release/build-msix), and added package-release-zips script.

These changes prepare the project for a formal 1.1.1 release with installer distribution, improved elevation handling and onboarding, plus enhanced import/export and custom power plan support.
2026-04-14 03:22:06 +02:00

140 lines
4.5 KiB
C#

/*
* ThreadPilot - Advanced Windows Process and Power Plan Manager
* Copyright (C) 2025 Prime Build
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, version 3 only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace ThreadPilot.Services
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ThreadPilot.Models;
/// <summary>
/// Interface for managing process-power plan associations.
/// </summary>
public interface IProcessPowerPlanAssociationService
{
/// <summary>
/// Event fired when configuration changes
/// </summary>
event EventHandler<ConfigurationChangedEventArgs>? ConfigurationChanged;
/// <summary>
/// Gets the current configuration.
/// </summary>
ProcessMonitorConfiguration Configuration { get; }
/// <summary>
/// Loads configuration from persistent storage.
/// </summary>
Task<bool> LoadConfigurationAsync();
/// <summary>
/// Saves configuration to persistent storage.
/// </summary>
Task<bool> SaveConfigurationAsync();
/// <summary>
/// Gets all associations.
/// </summary>
Task<IEnumerable<ProcessPowerPlanAssociation>> GetAssociationsAsync();
/// <summary>
/// Gets enabled associations only.
/// </summary>
Task<IEnumerable<ProcessPowerPlanAssociation>> GetEnabledAssociationsAsync();
/// <summary>
/// Adds a new association.
/// </summary>
Task<bool> AddAssociationAsync(ProcessPowerPlanAssociation association);
/// <summary>
/// Updates an existing association.
/// </summary>
Task<bool> UpdateAssociationAsync(ProcessPowerPlanAssociation association);
/// <summary>
/// Removes an association.
/// </summary>
Task<bool> RemoveAssociationAsync(string associationId);
/// <summary>
/// Finds the best matching association for a process.
/// </summary>
Task<ProcessPowerPlanAssociation?> FindMatchingAssociationAsync(ProcessModel process);
/// <summary>
/// Finds association by executable name.
/// </summary>
Task<ProcessPowerPlanAssociation?> FindAssociationByExecutableAsync(string executableName);
/// <summary>
/// Sets the default power plan.
/// </summary>
Task<bool> SetDefaultPowerPlanAsync(string powerPlanGuid, string powerPlanName);
/// <summary>
/// Gets the default power plan.
/// </summary>
Task<(string Guid, string Name)> GetDefaultPowerPlanAsync();
/// <summary>
/// Validates the current configuration.
/// </summary>
Task<IEnumerable<string>> ValidateConfigurationAsync();
/// <summary>
/// Resets configuration to defaults.
/// </summary>
Task ResetConfigurationAsync();
/// <summary>
/// Exports configuration to a file.
/// </summary>
Task<bool> ExportConfigurationAsync(string filePath);
/// <summary>
/// Imports configuration from a file.
/// </summary>
Task<bool> ImportConfigurationAsync(string filePath);
/// <summary>
/// Replaces the current configuration and persists it.
/// </summary>
Task<bool> ReplaceConfigurationAsync(ProcessMonitorConfiguration configuration);
}
/// <summary>
/// Event arguments for configuration changes.
/// </summary>
public class ConfigurationChangedEventArgs : EventArgs
{
public string ChangeType { get; }
public ProcessPowerPlanAssociation? Association { get; }
public string? Details { get; }
public ConfigurationChangedEventArgs(string changeType, ProcessPowerPlanAssociation? association = null, string? details = null)
{
this.ChangeType = changeType;
this.Association = association;
this.Details = details;
}
}
}