-
Notifications
You must be signed in to change notification settings - Fork 1
/
ContextSettings.cs
72 lines (66 loc) · 3.86 KB
/
ContextSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace FLogS
{
public partial class ContextSettings : INotifyPropertyChanged
{
private DateTime? _afterDate;
private DateTime? _beforeDate;
private bool _canRun = false;
private string _corruptedTimestamps = "Corrupted Timestamps:";
private bool? _divideLogs = false;
private string _emptyMessages = "Empty Messages:";
private string _exception = "";
private string _intactMessages = "Intact Messages:";
private string _logHeader = "Ready to receive data.";
private double _progress = 0.0;
private double _progressMax = 100.0;
private bool? _regex = false;
private string _runLabel = "Run";
private bool? _saveHTML = false;
private bool? _saveTruncated = false;
private string _themeLabel = "Dark";
private string _truncatedMessages = "Truncated Messages:";
private string _unreadData = "Unread Data:";
private readonly string _versionString = "FLogS — v. " + Assembly.GetExecutingAssembly().GetName().Version + " © Taica, " + GetBuildYear(Assembly.GetExecutingAssembly());
private string _warningText = Common.GetErrorMessage(ErrorCode.NO_SOURCE, WarningCode.None);
public DateTime? AfterDate { get => _afterDate; set { _afterDate = value; OnPropertyChanged(); } }
public DateTime? BeforeDate { get => _beforeDate; set { _beforeDate = value; OnPropertyChanged(); } }
public bool CanRun { get => _canRun; set { _canRun = value; OnPropertyChanged(); } }
public string CorruptedTimestamps { get => _corruptedTimestamps; set { _corruptedTimestamps = value; OnPropertyChanged(); } }
public bool? DivideLogs { get => _divideLogs; set { _divideLogs = value; OnPropertyChanged(); } }
public string EmptyMessages { get => _emptyMessages; set { _emptyMessages = value; OnPropertyChanged(); } }
public string Exception { get => _exception; set { _exception = value; OnPropertyChanged(); } }
public string IntactMessages { get => _intactMessages; set { _intactMessages = value; OnPropertyChanged(); } }
public string LogHeader { get => _logHeader; set { _logHeader = value; OnPropertyChanged(); } }
public double Progress { get => _progress; set { _progress = value; OnPropertyChanged(); } }
public double ProgressMax { get => _progressMax; set { _progressMax = value; OnPropertyChanged(); } }
public event PropertyChangedEventHandler? PropertyChanged;
public string RunLabel { get => _runLabel; set { _runLabel = value; OnPropertyChanged(); } }
public bool? Regex { get => _regex; set { _regex = value; OnPropertyChanged(); } }
public bool? SaveHTML { get => _saveHTML; set { _saveHTML = value; OnPropertyChanged(); } }
public bool? SaveTruncated { get => _saveTruncated; set { _saveTruncated = value; OnPropertyChanged(); } }
public string ThemeLabel { get => _themeLabel; set { _themeLabel = value; OnPropertyChanged(); } }
public string TruncatedMessages { get => _truncatedMessages; set { _truncatedMessages = value; OnPropertyChanged(); } }
public string UnreadData { get => _unreadData; set { _unreadData = value; OnPropertyChanged(); } }
public string VersionString => _versionString;
public string WarningText { get => _warningText; set { _warningText = value; OnPropertyChanged(); } }
private static int GetBuildYear(Assembly assembly)
{
const string prefix = "+build";
var attr = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
string? value = attr?.InformationalVersion;
int index = value?.IndexOf(prefix) ?? 0;
if (index > 0 && DateTime.TryParseExact(value?[(index + prefix.Length)..], "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var result))
return result.Year;
return default;
}
protected void OnPropertyChanged([CallerMemberName] string? name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
}