Skip to content

Commit 3912f76

Browse files
authored
Merge pull request #423 from LogExperts/removed_configManager_from_paintHelper
Removed config manager from paint helper
2 parents 2783962 + 7f4400b commit 3912f76

18 files changed

Lines changed: 303 additions & 264 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace LogExpert.Core.Classes.Highlight;
2+
3+
/// <summary>
4+
/// Class for storing word-wise highlight matches. Used for colouring different matches on one line.
5+
/// </summary>
6+
public class HighlightMatchEntry
7+
{
8+
#region Properties
9+
10+
public HighlightEntry HighlightEntry { get; set; }
11+
12+
public int StartPos { get; set; }
13+
14+
public int Length { get; set; }
15+
16+
#endregion
17+
18+
#region Public methods
19+
20+
public override string ToString ()
21+
{
22+
return $"{HighlightEntry.SearchText}/{StartPos}/{Length}";
23+
}
24+
25+
#endregion
26+
}

src/LogExpert.Core/Classes/Highlight/HilightMatchEntry.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/LogExpert.Core/Config/ColorMode.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Drawing;
2-
using System.Runtime.InteropServices;
1+
using System.Drawing;
32

43
namespace LogExpert.Core.Config;
54

@@ -10,8 +9,8 @@ public static class ColorMode
109
private static readonly Color BrightBookmarkDefaultSystemColor = SystemColors.Control; // Important: only supports SystemColors
1110
private static readonly Color LessBrightBackgroundColor = Color.FromArgb(208, 205, 206);
1211
private static readonly Color BrightBackgroundColor = Color.FromArgb(221, 221, 221);
13-
private static readonly Color BrighterBackgroundColor = Color.FromArgb(253, 253, 253);
14-
private static readonly Color BrightForeColor = Color.FromArgb(0, 0, 0);
12+
private static readonly Color BrighterBackgroundColor = Color.White;
13+
private static readonly Color BrightForeColor = Color.Black;
1514

1615
// Dark Theme
1716
// https://paletton.com/#uid=15-0u0k005U0670008J003Y003Y
@@ -20,7 +19,7 @@ public static class ColorMode
2019
private static readonly Color LessDarkBackgroundColor = Color.FromArgb(67, 67, 67);
2120
private static readonly Color DarkBackgroundColor = Color.FromArgb(45, 45, 45);
2221
private static readonly Color DarkerBackgroundColor = Color.FromArgb(30, 30, 30);
23-
private static readonly Color DarkForeColor = Color.FromArgb(255, 255, 255);
22+
private static readonly Color DarkForeColor = Color.White;
2423

2524
// Default
2625
public static Color BackgroundColor = BrightBackgroundColor;
@@ -35,7 +34,7 @@ public static class ColorMode
3534

3635
public static bool DarkModeEnabled;
3736

38-
public static void LoadColorMode(bool darkMode)
37+
public static void LoadColorMode (bool darkMode)
3938
{
4039
if (darkMode)
4140
{
@@ -47,7 +46,7 @@ public static void LoadColorMode(bool darkMode)
4746
}
4847
}
4948

50-
private static void SetDarkMode()
49+
private static void SetDarkMode ()
5150
{
5251
BackgroundColor = DarkBackgroundColor;
5352
ForeColor = DarkForeColor;
@@ -61,7 +60,7 @@ private static void SetDarkMode()
6160
DarkModeEnabled = true;
6261
}
6362

64-
private static void SetBrightMode()
63+
private static void SetBrightMode ()
6564
{
6665
BackgroundColor = BrightBackgroundColor;
6766
ForeColor = BrightForeColor;

src/LogExpert.Core/Interface/ISharedToolWindow.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using LogExpert.Core.Config;
1+
using LogExpert.Core.Config;
22

33
namespace LogExpert.Core.Interface;
44

@@ -15,16 +15,16 @@ public interface ISharedToolWindow
1515
/// Called when a file becomes the active file (e.g. when user selects a tab).
1616
/// </summary>
1717
/// <param name="ctx"></param>
18-
void SetCurrentFile(IFileViewContext ctx);
18+
void SetCurrentFile (IFileViewContext ctx);
1919

2020
/// <summary>
2121
/// Called whenever the current file has been changed.
2222
/// </summary>
23-
void FileChanged();
23+
void FileChanged ();
2424

25-
void SetColumnizer(ILogLineColumnizer columnizer);
25+
void SetColumnizer (ILogLineColumnizer columnizer);
2626

27-
void PreferencesChanged(Preferences newPreferences, bool isLoadTime, SettingsFlags flags);
27+
void PreferencesChanged (string fontName, float fontSize, bool setLastColumnWidth, int lastColumnWidth, SettingsFlags flags);
2828

2929
#endregion
3030
}

src/LogExpert.UI/Controls/BufferedDataGridView.Designer.cs

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/LogExpert.UI/Controls/BufferedDataGridView.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ internal partial class BufferedDataGridView : DataGridView
1414
{
1515
#region Fields
1616

17-
private static readonly ILogger _logger = LogManager.GetCurrentClassLogger();
17+
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
1818
private readonly Brush _brush;
1919

20-
private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 00);
20+
private readonly Color _bubbleColor = Color.FromArgb(160, 250, 250, 0);
2121
private readonly Font _font = new("Arial", 10);
2222

2323
private readonly SortedList<int, BookmarkOverlay> _overlayList = [];
@@ -230,9 +230,11 @@ private void PaintOverlays (PaintEventArgs e)
230230

231231
base.OnPaint(args);
232232

233-
StringFormat format = new();
234-
format.LineAlignment = StringAlignment.Center;
235-
format.Alignment = StringAlignment.Near;
233+
StringFormat format = new()
234+
{
235+
LineAlignment = StringAlignment.Center,
236+
Alignment = StringAlignment.Near
237+
};
236238

237239
myBuffer.Graphics.SetClip(DisplayRectangle, CombineMode.Intersect);
238240

@@ -247,8 +249,7 @@ private void PaintOverlays (PaintEventArgs e)
247249
foreach (BookmarkOverlay overlay in _overlayList.Values)
248250
{
249251
SizeF textSize = myBuffer.Graphics.MeasureString(overlay.Bookmark.Text, _font, 300);
250-
Rectangle rectBubble = new(overlay.Position,
251-
new Size((int)textSize.Width, (int)textSize.Height));
252+
Rectangle rectBubble = new(overlay.Position, new Size((int)textSize.Width, (int)textSize.Height));
252253
rectBubble.Offset(60, -(rectBubble.Height + 40));
253254
rectBubble.Inflate(3, 3);
254255
rectBubble.Location += overlay.Bookmark.OverlayOffset;
@@ -264,7 +265,7 @@ private void PaintOverlays (PaintEventArgs e)
264265

265266
if (_logger.IsDebugEnabled)
266267
{
267-
_logger.Debug("ClipRgn: {0},{1},{2},{3}", myBuffer.Graphics.ClipBounds.Left, myBuffer.Graphics.ClipBounds.Top, myBuffer.Graphics.ClipBounds.Width, myBuffer.Graphics.ClipBounds.Height);
268+
_logger.Debug($"ClipRgn: {myBuffer.Graphics.ClipBounds.Left},{myBuffer.Graphics.ClipBounds.Top},{myBuffer.Graphics.ClipBounds.Width},{myBuffer.Graphics.ClipBounds.Height}");
268269
}
269270
}
270271
}

src/LogExpert.UI/Controls/LogWindow/LogWindow.cs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, IL
3232
private const int SPREAD_MAX = 99;
3333
private const int PROGRESS_BAR_MODULO = 1000;
3434
private const int FILTER_ADVANCED_SPLITTER_DISTANCE = 150;
35-
private static readonly ILogger _logger = LogManager.GetCurrentClassLogger();
35+
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
3636

3737
private readonly Image _advancedButtonImage;
3838

3939
private readonly object _bookmarkLock = new();
4040
private readonly BookmarkDataProvider _bookmarkProvider = new();
4141

42-
private readonly IList<IBackgroundProcessCancelHandler> _cancelHandlerList = new List<IBackgroundProcessCancelHandler>();
42+
private readonly IList<IBackgroundProcessCancelHandler> _cancelHandlerList = [];
4343

4444
private readonly object _currentColumnizerLock = new();
4545

4646
private readonly object _currentHighlightGroupLock = new();
4747

4848
private readonly EventWaitHandle _externaLoadingFinishedEvent = new ManualResetEvent(false);
4949

50-
private readonly IList<FilterPipe> _filterPipeList = new List<FilterPipe>();
50+
private readonly IList<FilterPipe> _filterPipeList = [];
5151
private readonly Dictionary<Control, bool> _freezeStateMap = [];
5252
private readonly GuiStateArgs _guiStateArgs = new();
5353

@@ -141,10 +141,11 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp
141141
{
142142
SuspendLayout();
143143

144+
//HighDPI Functionality must be called before all UI Elements are initialized, to make sure they work as intended
144145
AutoScaleDimensions = new SizeF(96F, 96F);
145146
AutoScaleMode = AutoScaleMode.Dpi;
146147

147-
InitializeComponent(); //TODO: Move this to be the first line of the constructor?
148+
InitializeComponent();
148149

149150
CreateDefaultViewStyle();
150151

@@ -210,15 +211,9 @@ public LogWindow (LogTabWindow.LogTabWindow parent, string fileName, bool isTemp
210211

211212
_timeShiftSyncTask = new Task(SyncTimestampDisplayWorker, cts.Token);
212213
_timeShiftSyncTask.Start();
213-
//_timeShiftSyncThread = new Thread(SyncTimestampDisplayWorker);
214-
//_timeShiftSyncThread.IsBackground = true;
215-
//_timeShiftSyncThread.Start();
216214

217215
_logEventHandlerTask = new Task(LogEventWorker, cts.Token);
218216
_logEventHandlerTask.Start();
219-
//_logEventHandlerThread = new Thread(LogEventWorker);
220-
//_logEventHandlerThread.IsBackground = true;
221-
//_logEventHandlerThread.Start();
222217

223218
//this.filterUpdateThread = new Thread(new ThreadStart(this.FilterUpdateWorker));
224219
//this.filterUpdateThread.Start();
@@ -355,7 +350,7 @@ public void ChangeTheme (Control.ControlCollection container)
355350

356351
for (var y = 0; y < filterContextMenuStrip.Items.Count; y++)
357352
{
358-
var item = filterContextMenuStrip.Items[y];
353+
ToolStripItem item = filterContextMenuStrip.Items[y];
359354
item.ForeColor = ColorMode.ForeColor;
360355
item.BackColor = ColorMode.MenuBackgroundColor;
361356
}
@@ -482,26 +477,17 @@ public bool IsMultiFile
482477

483478
internal FilterPipe FilterPipe { get; set; }
484479

485-
public string Title
486-
{
487-
get
488-
{
489-
if (IsTempFile)
490-
{
491-
return TempTitleName;
492-
}
493-
494-
return FileName;
495-
}
496-
}
480+
public string Title => IsTempFile
481+
? TempTitleName
482+
: FileName;
497483

498484
public ColumnizerCallback ColumnizerCallbackObject { get; }
499485

500486
public bool ForcePersistenceLoading { get; set; }
501487

502488
public string ForcedPersistenceFileName { get; set; }
503489

504-
public Preferences Preferences => ConfigManager.Settings.Preferences;
490+
public Preferences Preferences => _parentLogTabWin.Preferences;
505491

506492
public string GivenFileName { get; set; }
507493

@@ -601,11 +587,13 @@ internal void ChangeMultifileMask ()
601587
internal void ToggleColumnFinder (bool show, bool setFocus)
602588
{
603589
_guiStateArgs.ColumnFinderVisible = show;
590+
604591
if (show)
605592
{
606593
columnComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
607594
columnComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
608595
columnComboBox.AutoCompleteCustomSource = [.. CurrentColumnizer.GetColumnNames()];
596+
609597
if (setFocus)
610598
{
611599
columnComboBox.Focus();

src/LogExpert.UI/Controls/LogWindow/LogWindow.designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/LogExpert.UI/Controls/LogWindow/LogWindowEventHandlers.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ protected void OnDeRegisterCancelHandler (IBackgroundProcessCancelHandler handle
104104
[SupportedOSPlatform("windows")]
105105
private void OnLogWindowLoad (object sender, EventArgs e)
106106
{
107-
PreferencesChanged(_parentLogTabWin.Preferences, true, SettingsFlags.GuiOrColors);
107+
var setLastColumnWidth = _parentLogTabWin.Preferences.SetLastColumnWidth;
108+
var lastColumnWidth = _parentLogTabWin.Preferences.LastColumnWidth;
109+
var fontName = _parentLogTabWin.Preferences.FontName;
110+
var fontSize = _parentLogTabWin.Preferences.FontSize;
111+
112+
PreferencesChanged(fontName, fontSize, setLastColumnWidth, lastColumnWidth, true, SettingsFlags.GuiOrColors);
108113
}
109114

110115
[SupportedOSPlatform("windows")]

0 commit comments

Comments
 (0)