9a4baba19a
* feat: back up persistent rules and resolve rule precedence deterministically
- Configuration export now includes persistent process rules (schema 3.0),
stays compatible with 2.0 bundles, validates before writing, previews
what an import replaces and rolls back on failure.
- Matching rules apply broad-to-specific (name, wildcard path, exact path,
then most recently edited), shared by the engine and the process summary,
which now lists the apply order and flags conflicting values.
- Localized the new strings in all seven languages.
* feat: clearer process and rule editors
- Process details: CPU, memory and I/O priority pickers with an explicit
Apply, undo of the last manual priority change (guarded against reused
PIDs), adaptive side/bottom details panel.
- Manual process control stays available while automation is paused, with
a persistent notice instead of an overlay.
- Saved-rule editor stages all edits (including the core mask) and saves
them together, showing pending changes.
- Localized the new strings in all seven languages.
* fix: one save path for a saved rule's cores
The rules editor's core mask went through a new update path that reported
success without saving when no affinity payload was built, and kept a
legacy mask next to a CPU selection. Merge it with the old single-purpose
method (now unused), keep its checks, and localize the undo message.
* feat: per-process efficiency mode (EcoQoS) for live processes and rules
Closes #66.
- Native: SetProcessInformation/GetProcessInformation with
ProcessPowerThrottling (EXECUTION_SPEED), three states: Windows decides,
On (EcoQoS), Off (never throttle / HighQoS).
- Process tab: context menu entries, a picker with Apply in the details
panel, current state in the summary, undo of the last change, included
when saving current settings as a rule (only if explicitly set).
- Rules: EfficiencyMode + ApplyEfficiencyModeOnStart, applied by the rules
engine, editable in the saved-rule editor, validated on import and part
of conflict detection.
- The summary flags when the global Power Throttling tweak voids it. CPU
priority is left alone, unlike Task Manager's efficiency mode.
- Localized in all seven languages.
* chore: keep CRLF line endings in SelectedProcessSummaryViewModel
* feat: clearer navigation, process page and rules editor
- Navigation pane open with short labels instead of seven bare icons.
- Processes: one toolbar row (search with placeholder, Filters and
Columns menus, sort, refresh); details split into Process, Priority,
CPU cores and Rule cards; pickers start from the process's current
values and stay empty when a value cannot be read; help paragraphs
moved into tooltips; core picker always visible.
- Rules: process rules first, clearer tab names, localized choices in the
saved-rule editor instead of internal enum names.
- Shorter page titles and subtitles in all seven languages; removed the
strings this made unused.
No data format changes.
* feat: settings and tweaks as Windows 11 rows, localized rule list
- Settings: one column of rows (what it is on the left, its switch on the
right), most used sections first, Save as the primary action.
- Tweaks: one tweak per row with its status dot and switch.
- Rule list: 'Applies' and 'Mode' columns use the same localized labels as
the editor and refresh on language change.
- Removed 76 strings no code referenced, from all seven languages.
* fix: issues found testing the beta in a clean Windows 11 VM
- Process counter could show more visible processes than the total
('157 / 151'): the batch total was a snapshot from the first load.
- Narrow windows (or 150% scaling): toolbar buttons move under the search
box instead of squeezing it to a few letters.
- Rules list keeps the 'Applies' column readable when narrow.
- Settings status message gets its own line instead of being cut.
Tested in a Hyper-V Windows 11 VM: clean install, upgrade, uninstall,
light and dark theme, 100% and 150% scaling.
* feat: remember layout choices; Windows 11 toggles in Tweaks
- The navigation pane, window size/position/maximized state, and the
process list filters, sort and columns now survive a restart. They live
in ui-state.json, apart from settings.json, so they never mark the
Settings page as unsaved or travel in exported configurations. A corrupt
file falls back to defaults; tests write to a temp file.
- Fixes the pane re-opening on every start (it was hard-coded open).
- Tweaks use a native-looking Windows 11 switch (40x20 track, sliding
thumb) with On/Off written beside it.
- New test: every on/off setting survives save and reload.
* docs: handoff for the 1.7.7 PR stack and beta test
* fix: P/E cores from the highest EfficiencyClass, AMD CCDs from real L3 groups
The legacy topology treated the lowest EfficiencyClass as the performance
core, swapping P- and E-cores on hybrid Intel CPUs. AMD CCDs were guessed
as 8 cores each, which split 6+6 parts (7900X3D, 9900X3D) into 8+4; they now
come from the L3 groups Windows reports, with the guess kept only as a
fallback. The topology snapshot also keeps each L3 group's size.
* feat: Game Boost, CPU Sets for the game and selected background apps
While a detected game runs, Game Boost sets process default CPU Sets from
the CPU topology: on AMD X3D with one larger L3 the game goes to the V-Cache
CCD, on Intel hybrid CPUs to the P-cores, and selected background apps
(browsers, sync clients, updaters, launchers) to the other cores. On dual-CCD
parts with equal L3 only the background moves, unless Isolation mode also
keeps the game on CCD0. Single-L3 and unreadable topologies are left to
Windows. Above Normal priority for the game is optional; never High.
Each change is written to a journal before it is made and undone when the
game exits, Game Boost is turned off or ThreadPilot closes, and on the next
start after a crash. Only values still exactly as Game Boost set them are
restored, never one a user rule or a manual change has taken over since.
Persistent rules and Game Boost share one apply gate, and a rule always
wins over Game Boost for the setting it covers.
The switch, mode and lists are on the Tweaks page, off by default, and take
effect without a restart.
* fix: Game Boost background entries with a full path never matched
The background list compared full-path entries against an empty path, so
only bare process names worked. Found by a new integration test that runs
the real services on two copies of PING.EXE: CPU Sets and priority are set
and read back through Windows, removed when Game Boost is turned off, and
undone from the journal after a simulated crash. The topology is simulated
from this machine's CPU Set IDs, so the test also runs on CPUs where Game
Boost would not act; it skips itself below 8 cores.
* feat: report Game Boost sessions and restore results in Activity
* test: diagnose EcoQoS read failures on Windows Server
* chore: prepare 1.7.7-beta.2 and keep prereleases out of stable channels
* test: use native full-query access mask in EcoQoS diagnostic
* docs: update beta handoff and prerelease publication policy
* ci: run native EcoQoS tests on a Windows 11-era kernel
Windows Server 2022 build 20348 rejects GetProcessInformation(ProcessPowerThrottling) with ERROR_INVALID_PARAMETER (87), with both limited and full query handles. Windows 11 local tests pass. Use Server 2025 for CI/release tests and smoke testing; keep the real round-trip assertions, remove temporary probes.
* test: lock beta publication and native runner contracts
* chore: separate stable 1.7.7 from experimental Game Boost
Stable retains the validated EcoQoS/rules/UI stack. Preserve the complete local Game Boost implementation at ef2ec24 for the separate 1.7.8-beta.1 prerelease; no experimental Game Boost/topology changes ship in stable. Keep channel-aware publication and Windows 11-era native CI tests.
483 lines
19 KiB
C#
483 lines
19 KiB
C#
/*
|
|
* ThreadPilot - lightweight selected process summary view model.
|
|
*/
|
|
namespace ThreadPilot.ViewModels
|
|
{
|
|
using System.Diagnostics;
|
|
using System.Threading;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using ThreadPilot.Models;
|
|
using ThreadPilot.Services;
|
|
|
|
public sealed class SelectedProcessSummaryViewModel : ObservableObject
|
|
{
|
|
private readonly IProcessMemoryPriorityService? memoryPriorityService;
|
|
private readonly IPersistentProcessRuleStore? persistentRuleStore;
|
|
private readonly IPersistentProcessRuleMatcher? persistentRuleMatcher;
|
|
private readonly ILocalizationService? localizationService;
|
|
private readonly Func<bool> isPowerThrottlingOff;
|
|
private bool hasSelection;
|
|
private int processId;
|
|
private string processName = string.Empty;
|
|
private string executablePath = string.Empty;
|
|
private double cpuUsage;
|
|
private long memoryUsage;
|
|
private ProcessPriorityClass cpuPriority;
|
|
private long processorAffinity;
|
|
private ProcessMemoryPriority? memoryPriority;
|
|
private ProcessIoPriority? ioPriority;
|
|
private ProcessEfficiencyMode? efficiencyMode;
|
|
private string efficiencyModeText = "Efficiency mode unavailable";
|
|
private bool isEfficiencyModeVoided;
|
|
private string processTitle = "No process selected";
|
|
private string currentProcessStatusText = "No process selected";
|
|
private string cpuUsageText = "CPU: unavailable";
|
|
private string memoryUsageText = "Memory: unavailable";
|
|
private string cpuPriorityText = "CPU priority: unavailable";
|
|
private string memoryPriorityText = "Memory priority unavailable";
|
|
private string ioPriorityText = "I/O priority unavailable";
|
|
private string affinityText = "Affinity: unavailable";
|
|
private string ruleStatusText = "No saved rule";
|
|
private string lastOperationMessage = "No recent ThreadPilot action";
|
|
private string lastOperationSeverity = "Information";
|
|
private bool isProtectedOrAccessDenied;
|
|
private bool hasThreadPilotRule;
|
|
private int updateVersion;
|
|
|
|
public SelectedProcessSummaryViewModel(
|
|
IProcessMemoryPriorityService? memoryPriorityService = null,
|
|
IPersistentProcessRuleStore? persistentRuleStore = null,
|
|
IPersistentProcessRuleMatcher? persistentRuleMatcher = null,
|
|
ILocalizationService? localizationService = null,
|
|
Func<bool>? isPowerThrottlingOff = null)
|
|
{
|
|
this.isPowerThrottlingOff = isPowerThrottlingOff ?? (() => false);
|
|
this.memoryPriorityService = memoryPriorityService;
|
|
this.persistentRuleStore = persistentRuleStore;
|
|
this.persistentRuleMatcher = persistentRuleMatcher;
|
|
this.localizationService = localizationService;
|
|
this.Clear(version: 0, lastOperationMessage: null, lastOperationIsError: false);
|
|
}
|
|
|
|
public bool HasSelection
|
|
{
|
|
get => this.hasSelection;
|
|
private set => this.SetProperty(ref this.hasSelection, value);
|
|
}
|
|
|
|
public int ProcessId
|
|
{
|
|
get => this.processId;
|
|
private set => this.SetProperty(ref this.processId, value);
|
|
}
|
|
|
|
public string ProcessName
|
|
{
|
|
get => this.processName;
|
|
private set => this.SetProperty(ref this.processName, value);
|
|
}
|
|
|
|
public string ExecutablePath
|
|
{
|
|
get => this.executablePath;
|
|
private set => this.SetProperty(ref this.executablePath, value);
|
|
}
|
|
|
|
public double CpuUsage
|
|
{
|
|
get => this.cpuUsage;
|
|
private set => this.SetProperty(ref this.cpuUsage, value);
|
|
}
|
|
|
|
public long MemoryUsage
|
|
{
|
|
get => this.memoryUsage;
|
|
private set => this.SetProperty(ref this.memoryUsage, value);
|
|
}
|
|
|
|
public ProcessPriorityClass CpuPriority
|
|
{
|
|
get => this.cpuPriority;
|
|
private set => this.SetProperty(ref this.cpuPriority, value);
|
|
}
|
|
|
|
public long ProcessorAffinity
|
|
{
|
|
get => this.processorAffinity;
|
|
private set => this.SetProperty(ref this.processorAffinity, value);
|
|
}
|
|
|
|
public ProcessMemoryPriority? MemoryPriority
|
|
{
|
|
get => this.memoryPriority;
|
|
private set => this.SetProperty(ref this.memoryPriority, value);
|
|
}
|
|
|
|
public ProcessIoPriority? IoPriority
|
|
{
|
|
get => this.ioPriority;
|
|
private set => this.SetProperty(ref this.ioPriority, value);
|
|
}
|
|
|
|
public ProcessEfficiencyMode? EfficiencyMode
|
|
{
|
|
get => this.efficiencyMode;
|
|
private set => this.SetProperty(ref this.efficiencyMode, value);
|
|
}
|
|
|
|
public string EfficiencyModeText
|
|
{
|
|
get => this.efficiencyModeText;
|
|
private set => this.SetProperty(ref this.efficiencyModeText, value);
|
|
}
|
|
|
|
public bool IsEfficiencyModeVoided
|
|
{
|
|
get => this.isEfficiencyModeVoided;
|
|
private set => this.SetProperty(ref this.isEfficiencyModeVoided, value);
|
|
}
|
|
|
|
public string ProcessTitle
|
|
{
|
|
get => this.processTitle;
|
|
private set => this.SetProperty(ref this.processTitle, value);
|
|
}
|
|
|
|
public string CurrentProcessStatusText
|
|
{
|
|
get => this.currentProcessStatusText;
|
|
private set => this.SetProperty(ref this.currentProcessStatusText, value);
|
|
}
|
|
|
|
public string CpuUsageText
|
|
{
|
|
get => this.cpuUsageText;
|
|
private set => this.SetProperty(ref this.cpuUsageText, value);
|
|
}
|
|
|
|
public string MemoryUsageText
|
|
{
|
|
get => this.memoryUsageText;
|
|
private set => this.SetProperty(ref this.memoryUsageText, value);
|
|
}
|
|
|
|
public string CpuPriorityText
|
|
{
|
|
get => this.cpuPriorityText;
|
|
private set => this.SetProperty(ref this.cpuPriorityText, value);
|
|
}
|
|
|
|
public string MemoryPriorityText
|
|
{
|
|
get => this.memoryPriorityText;
|
|
private set => this.SetProperty(ref this.memoryPriorityText, value);
|
|
}
|
|
|
|
public string IoPriorityText
|
|
{
|
|
get => this.ioPriorityText;
|
|
private set => this.SetProperty(ref this.ioPriorityText, value);
|
|
}
|
|
|
|
public string AffinityText
|
|
{
|
|
get => this.affinityText;
|
|
private set => this.SetProperty(ref this.affinityText, value);
|
|
}
|
|
|
|
public string RuleStatusText
|
|
{
|
|
get => this.ruleStatusText;
|
|
private set => this.SetProperty(ref this.ruleStatusText, value);
|
|
}
|
|
|
|
public string LastOperationMessage
|
|
{
|
|
get => this.lastOperationMessage;
|
|
private set => this.SetProperty(ref this.lastOperationMessage, value);
|
|
}
|
|
|
|
public string LastOperationSeverity
|
|
{
|
|
get => this.lastOperationSeverity;
|
|
private set => this.SetProperty(ref this.lastOperationSeverity, value);
|
|
}
|
|
|
|
public bool IsProtectedOrAccessDenied
|
|
{
|
|
get => this.isProtectedOrAccessDenied;
|
|
private set => this.SetProperty(ref this.isProtectedOrAccessDenied, value);
|
|
}
|
|
|
|
public bool HasThreadPilotRule
|
|
{
|
|
get => this.hasThreadPilotRule;
|
|
private set => this.SetProperty(ref this.hasThreadPilotRule, value);
|
|
}
|
|
|
|
public async Task UpdateAsync(
|
|
ProcessModel? process,
|
|
string? lastOperationMessage = null,
|
|
bool lastOperationIsError = false)
|
|
{
|
|
var version = Interlocked.Increment(ref this.updateVersion);
|
|
if (process == null)
|
|
{
|
|
this.Clear(version, lastOperationMessage, lastOperationIsError);
|
|
return;
|
|
}
|
|
|
|
this.HasSelection = true;
|
|
this.ProcessId = process.ProcessId;
|
|
this.ProcessName = process.Name ?? string.Empty;
|
|
this.ExecutablePath = process.ExecutablePath ?? string.Empty;
|
|
this.CpuUsage = process.CpuUsage;
|
|
this.MemoryUsage = process.MemoryUsage;
|
|
this.CpuPriority = process.Priority;
|
|
this.ProcessorAffinity = process.ProcessorAffinity;
|
|
this.IsProtectedOrAccessDenied = process.Classification == ProcessClassification.ProtectedOrAccessDenied;
|
|
this.ProcessTitle = this.L("ProcessSummary_SelectedProcessFormat", "Selected process: {0} (PID {1})", this.ProcessName, this.ProcessId);
|
|
this.CurrentProcessStatusText = this.IsProtectedOrAccessDenied
|
|
? this.L("ProcessSummary_StatusProtected", "Current process status: protected or access denied")
|
|
: this.L("ProcessSummary_StatusSelected", "Current process status: selected");
|
|
this.CpuUsageText = this.L("ProcessSummary_CpuFormat", "CPU: {0:N1}%", this.CpuUsage);
|
|
this.MemoryUsageText = this.L("ProcessSummary_MemoryFormat", "Memory: {0}", FormatMemory(this.MemoryUsage));
|
|
this.CpuPriorityText = this.L("ProcessSummary_CpuPriorityFormat", "CPU priority: {0}", this.CpuPriority);
|
|
this.AffinityText = this.L("ProcessSummary_AffinityLegacyFormat", "Affinity: legacy mask 0x{0:X}", this.ProcessorAffinity);
|
|
this.UpdateLastOperation(lastOperationMessage, lastOperationIsError);
|
|
|
|
await this.UpdateMemoryPriorityAsync(process, version);
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
await this.UpdateIoPriorityAsync(process, version);
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
await this.UpdateEfficiencyModeAsync(process, version);
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
await this.UpdateRuleStatusAsync(process, version);
|
|
}
|
|
|
|
private static string FormatMemory(long bytes)
|
|
{
|
|
if (bytes <= 0)
|
|
{
|
|
return "0 MB";
|
|
}
|
|
|
|
var megabytes = bytes / 1024d / 1024d;
|
|
return $"{megabytes:N0} MB";
|
|
}
|
|
|
|
private void Clear(int version, string? lastOperationMessage, bool lastOperationIsError)
|
|
{
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.HasSelection = false;
|
|
this.ProcessId = 0;
|
|
this.ProcessName = string.Empty;
|
|
this.ExecutablePath = string.Empty;
|
|
this.CpuUsage = 0;
|
|
this.MemoryUsage = 0;
|
|
this.CpuPriority = default;
|
|
this.ProcessorAffinity = 0;
|
|
this.MemoryPriority = null;
|
|
this.IoPriority = null;
|
|
this.EfficiencyMode = null;
|
|
this.IsEfficiencyModeVoided = false;
|
|
this.IsProtectedOrAccessDenied = false;
|
|
this.HasThreadPilotRule = false;
|
|
this.ProcessTitle = this.L("ProcessView_NoProcessSelected", "No process selected");
|
|
this.CurrentProcessStatusText = this.L("ProcessView_NoProcessSelected", "No process selected");
|
|
this.CpuUsageText = this.L("ProcessSummary_CpuUnavailable", "CPU: unavailable");
|
|
this.MemoryUsageText = this.L("ProcessSummary_MemoryUnavailable", "Memory: unavailable");
|
|
this.CpuPriorityText = this.L("ProcessSummary_CpuPriorityUnavailable", "CPU priority: unavailable");
|
|
this.MemoryPriorityText = this.L("ProcessSummary_MemoryPriorityUnavailable", "Memory priority unavailable");
|
|
this.IoPriorityText = this.L("ProcessSummary_IoPriorityUnavailable", "I/O priority unavailable");
|
|
this.EfficiencyModeText = this.L("ProcessSummary_EfficiencyUnavailable", "Efficiency mode unavailable");
|
|
this.AffinityText = this.L("ProcessSummary_AffinityUnavailable", "Affinity: unavailable");
|
|
this.RuleStatusText = this.L("ProcessSummary_NoSavedRule", "No saved rule");
|
|
this.UpdateLastOperation(lastOperationMessage, lastOperationIsError);
|
|
}
|
|
|
|
private async Task UpdateMemoryPriorityAsync(ProcessModel process, int version)
|
|
{
|
|
this.MemoryPriority = null;
|
|
this.MemoryPriorityText = this.L("ProcessSummary_MemoryPriorityUnavailable", "Memory priority unavailable");
|
|
|
|
if (this.memoryPriorityService == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var priority = await this.memoryPriorityService.GetMemoryPriorityAsync(process);
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (priority == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.MemoryPriority = priority.Value;
|
|
this.MemoryPriorityText = this.L("ProcessSummary_MemoryPriorityFormat", "Memory priority: {0}", priority.Value);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.MemoryPriority = null;
|
|
this.MemoryPriorityText = this.L("ProcessSummary_MemoryPriorityUnavailable", "Memory priority unavailable");
|
|
}
|
|
}
|
|
|
|
private async Task UpdateIoPriorityAsync(ProcessModel process, int version)
|
|
{
|
|
this.IoPriority = null;
|
|
this.IoPriorityText = this.L("ProcessSummary_IoPriorityUnavailable", "I/O priority unavailable");
|
|
if (this.memoryPriorityService == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var priority = await this.memoryPriorityService.GetIoPriorityAsync(process);
|
|
if (!this.IsCurrentVersion(version) || priority == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.IoPriority = priority.Value;
|
|
this.IoPriorityText = this.L("ProcessSummary_IoPriorityFormat", "I/O priority: {0}", priority.Value);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
this.IoPriority = null;
|
|
}
|
|
}
|
|
|
|
private async Task UpdateEfficiencyModeAsync(ProcessModel process, int version)
|
|
{
|
|
this.EfficiencyMode = null;
|
|
this.IsEfficiencyModeVoided = false;
|
|
this.EfficiencyModeText = this.L("ProcessSummary_EfficiencyUnavailable", "Efficiency mode unavailable");
|
|
if (this.memoryPriorityService == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var mode = await this.memoryPriorityService.GetEfficiencyModeAsync(process);
|
|
if (!this.IsCurrentVersion(version) || mode == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.EfficiencyMode = mode.Value;
|
|
var label = this.L($"EfficiencyMode_{mode.Value}", mode.Value.ToString());
|
|
this.IsEfficiencyModeVoided = mode == ProcessEfficiencyMode.On && this.isPowerThrottlingOff();
|
|
this.EfficiencyModeText = this.IsEfficiencyModeVoided
|
|
? this.L("ProcessSummary_EfficiencyVoidedFormat", "Efficiency mode: {0} (no effect: power throttling is disabled in Tweaks)", label)
|
|
: this.L("ProcessSummary_EfficiencyFormat", "Efficiency mode: {0}", label);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
this.EfficiencyMode = null;
|
|
}
|
|
}
|
|
|
|
private async Task UpdateRuleStatusAsync(ProcessModel process, int version)
|
|
{
|
|
this.HasThreadPilotRule = false;
|
|
this.RuleStatusText = this.L("ProcessSummary_NoSavedRule", "No saved rule");
|
|
|
|
if (this.persistentRuleStore == null || this.persistentRuleMatcher == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var rules = await this.persistentRuleStore.LoadAsync();
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var matches = PersistentRuleResolution.MatchInApplyOrder(rules, process, this.persistentRuleMatcher);
|
|
if (matches.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.HasThreadPilotRule = true;
|
|
var names = string.Join(" → ", matches.Select(rule => string.IsNullOrWhiteSpace(rule.Name)
|
|
? this.L("ProcessSummary_SavedRuleFallback", "saved rule") : rule.Name.Trim()));
|
|
this.RuleStatusText = matches.Count == 1
|
|
? this.L("ProcessSummary_SavedRuleExistsFormat", "Saved rule exists: {0}", names)
|
|
: this.L("ProcessSummary_RuleOrder", "Rules in apply order: {0}. Later rules win for overlapping settings.", names);
|
|
if (PersistentRuleResolution.HasConflicts(matches))
|
|
{
|
|
this.RuleStatusText += " " + this.L("ProcessSummary_RuleConflict", "Conflicting values: review these rules.");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
if (!this.IsCurrentVersion(version))
|
|
{
|
|
return;
|
|
}
|
|
|
|
this.HasThreadPilotRule = false;
|
|
this.RuleStatusText = this.L("ProcessSummary_NoSavedRule", "No saved rule");
|
|
}
|
|
}
|
|
|
|
private bool IsCurrentVersion(int version) => Volatile.Read(ref this.updateVersion) == version;
|
|
|
|
private void UpdateLastOperation(string? message, bool isError)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(message))
|
|
{
|
|
this.LastOperationMessage = this.L("ProcessSummary_NoRecentAction", "No recent ThreadPilot action");
|
|
this.LastOperationSeverity = "Information";
|
|
return;
|
|
}
|
|
|
|
this.LastOperationMessage = message.Trim();
|
|
this.LastOperationSeverity = isError ? "Error" : "Information";
|
|
}
|
|
|
|
private string L(string key, string fallback, params object[] args)
|
|
{
|
|
var localized = this.localizationService?.GetString(key);
|
|
var format = string.IsNullOrWhiteSpace(localized) || string.Equals(localized, key, StringComparison.Ordinal)
|
|
? fallback
|
|
: localized;
|
|
|
|
return args.Length == 0 ? format : string.Format(format, args);
|
|
}
|
|
}
|
|
}
|