Files
ThreadPilot/Models/ProcessModel.cs
T
PrimeBuild-pc 594a3c4b85 Refactor MainWindow behaviors into partial class
Move and centralize MainWindow behavior/logic into a new partial file and tidy related viewmodel/service code.

- Add MainWindow.Behaviors.partial.cs containing initialization, loading overlay, view model loading, service setup, system tray management, monitoring lifecycle, keyboard shortcuts, elevation/performance overlays, graceful shutdown and related helpers (moved out of MainWindow.xaml.cs).
- Remove duplicated behavior code from MainWindow.xaml.cs.
- Add ProcessViewModel.Behaviors.partial.cs and update ViewModels/ProcessViewModel.cs to separate behavior logic from core viewmodel.
- Update Models/ProcessModel.cs and services (GameDetectionService.cs, ProcessMonitorService.cs, ProcessService.cs) to align with the refactor and improve robustness (timeouts, fallbacks, logging and error handling).

Reason: reduce MainWindow.xaml.cs size, improve separation of concerns and maintainability, and introduce more resilient startup/shutdown and tray/update logic.
2026-04-15 23:13:11 +02:00

71 lines
2.1 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.Models
{
using System;
using System.Diagnostics;
using CommunityToolkit.Mvvm.ComponentModel;
public partial class ProcessModel : ObservableObject
{
[ObservableProperty]
private int processId;
[ObservableProperty]
private string name = string.Empty;
[ObservableProperty]
private string executablePath = string.Empty;
[ObservableProperty]
private double cpuUsage;
[ObservableProperty]
private long memoryUsage;
[ObservableProperty]
private ProcessPriorityClass priority;
[ObservableProperty]
private long processorAffinity;
[ObservableProperty]
private IntPtr mainWindowHandle;
[ObservableProperty]
private string mainWindowTitle = string.Empty;
[ObservableProperty]
private bool hasVisibleWindow;
[ObservableProperty]
private bool isIdleServerDisabled;
[ObservableProperty]
private bool isRegistryPriorityEnabled;
/// <summary>
/// Forces PropertyChanged notification for ProcessorAffinity.
/// Used to update DataGrid binding when affinity changes from background thread.
/// </summary>
public void ForceNotifyProcessorAffinityChanged()
{
this.OnPropertyChanged(nameof(this.ProcessorAffinity));
}
}
}