using System.Drawing;
using System.Runtime.Versioning;
using LogExpert.Core.Entities;
using LogExpert.Core.Enums;
using LogExpert.Core.Helpers;
namespace LogExpert.Core.Config;
[Serializable]
public class Preferences
{
private SelectionHighlightSettings _selectionHighlight = new();
private int[] _highlightCustomColors = [];
public SelectionHighlightSettings SelectionHighlight
{
get => _selectionHighlight;
set => _selectionHighlight = value ?? new();
}
public int[] HighlightCustomColors
{
get => _highlightCustomColors;
set => _highlightCustomColors = value ?? [];
}
[Newtonsoft.Json.JsonProperty("HighlightGroupList")]
[System.Text.Json.Serialization.JsonPropertyName("HighlightGroupList")]
public List<HighlightGroup> HighlightGroupList { get; set; } = [];
[Obsolete("This property exists only for backward compatibility with old settings files. Use HighlightGroupList instead. This will be removed with version 1.50")]
[Newtonsoft.Json.JsonProperty("hilightGroupList", DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.Text.Json.Serialization.JsonIgnore]
public List<HighlightGroup> HilightGroupList
{
get => null;
set => HighlightGroupList = value ?? [];
}
public bool PortableMode { get; set; }
public ControlCharSettings ControlCharSettings { get; set; } = new();
[Obsolete("This setting is no longer used and will be removed in version 1.50. The 'Allow Only One Instance' feature now works silently.")]
[System.Text.Json.Serialization.JsonIgnore]
[Newtonsoft.Json.JsonIgnore]
public bool ShowErrorMessageAllowOnlyOneInstances { get; set; }
public int MaxLineLength { get; set; } = 20000;
public int MaxDisplayLength { get; set; } = 20000;
public bool AllowOnlyOneInstance { get; set; }
public bool AskForClose { get; set; }
public ColorMode ColorMode
{
get => _colorMode;
set
{
_colorMode = value;
_colorModeAssigned = true;
}
}
private ColorMode _colorMode = ColorMode.Light;
private bool _colorModeAssigned;
[Obsolete("This property exists only for backward compatibility with old settings files. Use ColorMode instead. This will be removed with version 1.50")]
[Newtonsoft.Json.JsonProperty("DarkMode", DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.Text.Json.Serialization.JsonIgnore]
public bool? DarkMode
{
get => null;
set
{
if (!_colorModeAssigned && value.HasValue)
{
_colorMode = value.Value ? ColorMode.Dark : ColorMode.Light;
}
}
}
[Obsolete("This setting is no longer used and will be removed in version 1.50. The 'UseLegacyReader' now works with ReaderType.Legacy")]
[System.Text.Json.Serialization.JsonIgnore]
[Newtonsoft.Json.JsonIgnore]
public bool UseLegacyReader { get; set; }
public ReaderType ReaderType { get; set; } = ReaderType.SystemDirect;
public List<ToolEntry> ToolEntries { get; set; } = [];
public DragOrientations TimestampControlDragOrientation { get; set; } = DragOrientations.Horizontal;
public bool TimestampControl { get; set; }
public bool TimeSpreadTimeMode { get; set; }
public string SessionSaveDirectory { get; set; }
public bool SaveFilters { get; set; } = true;
public SessionSaveLocation SaveLocation { get; set; } = SessionSaveLocation.DocumentsDir;
public bool SaveSessions { get; set; } = true;
public bool SetLastColumnWidth { get; set; }
public bool ShowBubbles { get; set; } = true;
public bool ShowMarkerBar { get; set; }
public bool ShowHighlightMarkers { get; set; } = true;
public bool ShowBookmarkMarkers { get; set; } = true;
public bool ShowSearchMarkers { get; set; } = true;
public bool ShowFilterMarkers { get; set; } = true;
public bool ShowColumnFinder { get; set; }
public Color ShowTailColor { get; set; } = Color.FromKnownColor(KnownColor.Blue);
public bool ShowTailState { get; set; } = true;
public bool ShowTimeSpread { get; set; }
public Color TimeSpreadColor { get; set; } = Color.FromKnownColor(KnownColor.Gray);
public bool IsAutoHideFilterList { get; set; }
public bool IsFilterOnLoad { get; set; }
public int LastColumnWidth { get; set; } = 2000;
public int LinesPerBuffer { get; set; } = 500;
public int MaximumFilterEntries { get; set; } = 30;
public int MaximumFilterEntriesDisplayed { get; set; } = 20;
[Obsolete("Replaced by ColumnizerSelectionPriority; will be removed in 1.50.")]
public bool MaskPrio { get; set; }
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public ColumnizerSelectionPriority ColumnizerSelectionPriority { get; set; } = ColumnizerSelectionPriority.HistoryThenMask;
public bool AutoPick { get; set; }
public MultiFileOption MultiFileOption { get; set; }
public MultiFileOptions MultiFileOptions { get; set; }
public bool MultiThreadFilter { get; set; } = true;
public bool OpenLastFiles { get; set; } = true;
public int PollingInterval { get; set; } = 250;
public bool ReverseAlpha { get; set; }
public int BufferCount { get; set; } = 100;
public List<ColumnizerMaskEntry> ColumnizerMaskList { get; set; } = [];
public string DefaultEncoding { get; set; } = "utf-8";
public string DefaultLanguage { get; set; } = "en-US";
public bool FilterSync { get; set; } = true;
public bool FilterTail { get; set; } = true;
public bool FollowTail { get; set; } = true;
[Obsolete("This setting is no longer used and will be removed in version 1.50. The 'FontString' will be used for Importing / Exporting the Font")]
public string FontName { get; set; } = "Courier New";
public string FontString { get; set; } = "Courier New, 9pt, style=Regular";
[System.Text.Json.Serialization.JsonIgnore]
[Newtonsoft.Json.JsonIgnore]
[SupportedOSPlatform("windows")]
public Font Font
{
get => field ??= FontHelper.ParseFontStringOrDefault(FontString);
set;
}
[Obsolete("This setting is no longer used and will be removed in version 1.50. The 'FontString' will be used for Importing / Exporting the Font")]
public float FontSize { get => field; set => field = MathF.Round(value, 1); } = 9.0f;
public List<HighlightMaskEntry> HighlightMaskList { get; set; } = [];
}