acfd8dca7e
Replaces the project's license from GNU GPL v3 to the GNU Affero General Public License v3: updated LICENSE (full AGPL text) and updated license headers across source files. Adds InternalsVisibleTo("ThreadPilot.Core.Tests") (plus using System.Runtime.CompilerServices) in AssemblyInfo to allow test access to internal types. Also introduces Services/TaskSafety.cs and two new test files under Tests/ThreadPilot.Core.Tests to cover task safety. These changes apply the AGPLv3 terms and enable internal API access for unit tests.
158 lines
4.4 KiB
C#
158 lines
4.4 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/>.
|
|
*/
|
|
using System;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
namespace ThreadPilot.Models
|
|
{
|
|
/// <summary>
|
|
/// Model representing a notification
|
|
/// </summary>
|
|
public partial class NotificationModel : ObservableObject
|
|
{
|
|
[ObservableProperty]
|
|
private string id = Guid.NewGuid().ToString();
|
|
|
|
[ObservableProperty]
|
|
private string title = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string message = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private NotificationType type = NotificationType.Information;
|
|
|
|
[ObservableProperty]
|
|
private DateTime timestamp = DateTime.Now;
|
|
|
|
[ObservableProperty]
|
|
private int durationMs = 3000;
|
|
|
|
[ObservableProperty]
|
|
private bool isRead = false;
|
|
|
|
[ObservableProperty]
|
|
private bool isPersistent = false;
|
|
|
|
[ObservableProperty]
|
|
private string? actionText;
|
|
|
|
[ObservableProperty]
|
|
private string? actionCommand;
|
|
|
|
[ObservableProperty]
|
|
private string? iconPath;
|
|
|
|
[ObservableProperty]
|
|
private NotificationPriority priority = NotificationPriority.Normal;
|
|
|
|
[ObservableProperty]
|
|
private string? category;
|
|
|
|
[ObservableProperty]
|
|
private string? sourceService;
|
|
|
|
/// <summary>
|
|
/// Creates a new notification
|
|
/// </summary>
|
|
public NotificationModel()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new notification with basic information
|
|
/// </summary>
|
|
public NotificationModel(string title, string message, NotificationType type = NotificationType.Information)
|
|
{
|
|
Title = title;
|
|
Message = message;
|
|
Type = type;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new notification with full information
|
|
/// </summary>
|
|
public NotificationModel(string title, string message, NotificationType type, int durationMs, bool isPersistent = false)
|
|
{
|
|
Title = title;
|
|
Message = message;
|
|
Type = type;
|
|
DurationMs = durationMs;
|
|
IsPersistent = isPersistent;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Marks the notification as read
|
|
/// </summary>
|
|
public void MarkAsRead()
|
|
{
|
|
IsRead = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the display text for the notification type
|
|
/// </summary>
|
|
public string TypeDisplayText => Type switch
|
|
{
|
|
NotificationType.Information => "Info",
|
|
NotificationType.Success => "Success",
|
|
NotificationType.Warning => "Warning",
|
|
NotificationType.Error => "Error",
|
|
NotificationType.PowerPlanChange => "Power Plan",
|
|
NotificationType.ProcessMonitoring => "Process Monitor",
|
|
NotificationType.CpuAffinity => "CPU Affinity",
|
|
_ => "Unknown"
|
|
};
|
|
|
|
/// <summary>
|
|
/// Gets the formatted timestamp
|
|
/// </summary>
|
|
public string FormattedTimestamp => Timestamp.ToString("HH:mm:ss");
|
|
|
|
/// <summary>
|
|
/// Gets the formatted date and time
|
|
/// </summary>
|
|
public string FormattedDateTime => Timestamp.ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Types of notifications
|
|
/// </summary>
|
|
public enum NotificationType
|
|
{
|
|
Information,
|
|
Success,
|
|
Warning,
|
|
Error,
|
|
PowerPlanChange,
|
|
ProcessMonitoring,
|
|
CpuAffinity
|
|
}
|
|
|
|
/// <summary>
|
|
/// Notification priority levels
|
|
/// </summary>
|
|
public enum NotificationPriority
|
|
{
|
|
Low,
|
|
Normal,
|
|
High,
|
|
Critical
|
|
}
|
|
}
|
|
|