Skip to content

Commit 60867e3

Browse files
committed
add partial History support code : model and viewModel
1 parent 5bcd661 commit 60867e3

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
3+
4+
namespace Avalonia.CpuLimiter.Models;
5+
6+
public class HistoryItem
7+
{
8+
public HistoryItem()
9+
{
10+
}
11+
12+
public HistoryItem(string path, DateTime lastUsed, int count)
13+
{
14+
15+
Path = path;
16+
LastUsed = lastUsed;
17+
CPUCoreUsed = count;
18+
}
19+
20+
public string? Path { get; set; }
21+
22+
public DateTime? LastUsed { get; set; }
23+
24+
public int? CPUCoreUsed { get; set; }
25+
26+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System;
2+
using Avalonia.CpuLimiter.Models;
3+
using ReactiveUI;
4+
5+
namespace Avalonia.CpuLimiter.ViewModels;
6+
7+
public class HistoryItemViewModel : ViewModelBase
8+
{
9+
public HistoryItemViewModel()
10+
{
11+
}
12+
13+
public HistoryItemViewModel(HistoryItem historyItem)
14+
{
15+
Path = historyItem.Path;
16+
LastUsed = historyItem.LastUsed;
17+
CPUCoreUsed = historyItem.CPUCoreUsed;
18+
}
19+
20+
private string? _path;
21+
public string? Path
22+
{
23+
get => _path;
24+
set => this.RaiseAndSetIfChanged(ref _path, value);
25+
}
26+
27+
private DateTime? _lastUsed;
28+
public DateTime? LastUsed
29+
{
30+
get => _lastUsed;
31+
set => this.RaiseAndSetIfChanged(ref _lastUsed, value);
32+
}
33+
34+
private int? _CPUCoreUsed;
35+
36+
public int? CPUCoreUsed
37+
{
38+
get => _CPUCoreUsed;
39+
set => this.RaiseAndSetIfChanged(ref _CPUCoreUsed, value);
40+
}
41+
42+
public HistoryItem GetHistoryItem()
43+
{
44+
return new HistoryItem()
45+
{
46+
Path = this.Path,
47+
CPUCoreUsed = this.CPUCoreUsed,
48+
LastUsed = this.LastUsed,
49+
};
50+
}
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
}

0 commit comments

Comments
 (0)