Skip to content

Commit 6911a07

Browse files
Randall FlaggRandall Flagg
authored andcommitted
Remove all UI code from the Core project
1 parent ab45d00 commit 6911a07

14 files changed

Lines changed: 121 additions & 109 deletions

File tree

src/LogExpert.Core/Classes/Filter/Filter.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using LogExpert.Classes.ILogLineColumnizerCallback;
22
using LogExpert.Core.Classes;
33
using LogExpert.Core.Classes.Filter;
4-
54
using NLog;
65

7-
using System;
8-
using System.Collections.Generic;
9-
using System.Windows.Forms;
10-
116
namespace LogExpert.Classes.Filter
127
{
138
internal delegate void FilterFx(FilterParams filterParams, List<int> filterResultLines, List<int> lastFilterResultLines, List<int> filterHitList);

src/LogExpert.Core/Classes/Util.cs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using LogExpert.Core.Classes.Filter;
2-
32
using System.Diagnostics;
43
using System.Drawing;
54
using System.Runtime.Versioning;
@@ -402,59 +401,6 @@ public static void AssertTrue(bool condition, string msg)
402401
}
403402
}
404403

405-
[SupportedOSPlatform("windows")]
406-
public string GetWordFromPos(int xPos, string text, Graphics g, Font font)
407-
{
408-
string[] words = text.Split([' ', '.', ':', ';']);
409-
410-
int index = 0;
411-
412-
List<CharacterRange> crList = [];
413-
414-
for (int i = 0; i < words.Length; ++i)
415-
{
416-
crList.Add(new CharacterRange(index, words[i].Length));
417-
index += words[i].Length;
418-
}
419-
420-
CharacterRange[] crArray = [.. crList];
421-
422-
StringFormat stringFormat = new(StringFormat.GenericTypographic)
423-
{
424-
Trimming = StringTrimming.None,
425-
FormatFlags = StringFormatFlags.NoClip
426-
};
427-
428-
stringFormat.SetMeasurableCharacterRanges(crArray);
429-
430-
RectangleF rect = new(0, 0, 3000, 20);
431-
Region[] stringRegions = g.MeasureCharacterRanges(text, font, rect, stringFormat);
432-
433-
bool found = false;
434-
435-
int y = 0;
436-
437-
foreach (Region regio in stringRegions)
438-
{
439-
if (regio.IsVisible(xPos, 3, g))
440-
{
441-
found = true;
442-
break;
443-
}
444-
445-
y++;
446-
}
447-
448-
if (found)
449-
{
450-
return words[y];
451-
}
452-
else
453-
{
454-
return null;
455-
}
456-
}
457-
458404
#endregion
459405

460406
#region Private Methods

src/LogExpert.Core/Entities/FileViewContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace LogExpert.Core.Entities
44
{
5-
public class FileViewContext(ILogPaintContext logPaintContext, ILogView logView)
5+
public class FileViewContext(ILogPaintContext logPaintContext, ILogView logView) : IFileViewContext, ILogPaintContext
66
{
77
#region Properties
88

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using LogExpert.Core.Entities;
2+
3+
namespace LogExpert.Core.Interface
4+
{
5+
public interface IFileViewContext
6+
{
7+
ILogView LogView { get; }
8+
ILogPaintContext LogPaintContext { get; }
9+
}
10+
}
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,6 @@
1-
using LogExpert.Core.Classes.Highlight;
2-
using LogExpert.Core.Entities;
3-
4-
using System.Drawing;
5-
6-
namespace LogExpert.Core.Interface
1+
namespace LogExpert.Core.Interface
72
{
8-
/// <summary>
9-
/// Declares methods that are needed for drawing log lines. Used by PaintHelper.
10-
/// </summary>
113
public interface ILogPaintContext
124
{
13-
#region Properties
14-
15-
Font MonospacedFont { get; } // Font font = new Font("Courier New", this.Preferences.fontSize, FontStyle.Bold);
16-
Font NormalFont { get; }
17-
Font BoldFont { get; }
18-
Color BookmarkColor { get; }
19-
20-
#endregion
21-
22-
#region Public methods
23-
24-
ILogLine GetLogLine(int lineNum);
25-
26-
IColumn GetCellValue(int rowIndex, int columnIndex);
27-
28-
Bookmark GetBookmarkForLine(int lineNum);
29-
30-
HighlightEntry FindHighlightEntry(ITextValue line, bool noWordMatches);
31-
32-
IList<HilightMatchEntry> FindHighlightMatches(ITextValue line);
33-
34-
#endregion
355
}
366
}

src/LogExpert.Core/Interface/ISharedToolWindow.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using LogExpert.Core.Config;
2-
using LogExpert.Core.Entities;
32

43
namespace LogExpert.Core.Interface
54
{
@@ -16,7 +15,7 @@ public interface ISharedToolWindow
1615
/// Called when a file becomes the active file (e.g. when user selects a tab).
1716
/// </summary>
1817
/// <param name="ctx"></param>
19-
void SetCurrentFile(FileViewContext ctx);
18+
void SetCurrentFile(IFileViewContext ctx);
2019

2120
/// <summary>
2221
/// Called whenever the current file has been changed.

src/LogExpert.Core/LogExpert.Core.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
<SignAssembly>True</SignAssembly>
1010
<AssemblyOriginatorKeyFile>..\Solution Items\Key.snk</AssemblyOriginatorKeyFile>
11+
<PublishAot>false</PublishAot>
12+
<NoWarn>CS8625;CS8603;CS8618;CS8600;CS8603;CS8602;CS8604;CS8622;CS8601;</NoWarn>
1113
</PropertyGroup>
1214

1315
<ItemGroup>
@@ -21,7 +23,6 @@
2123
<ItemGroup>
2224
<PackageReference Include="Newtonsoft.Json" />
2325
<PackageReference Include="NLog" />
24-
<PackageReference Include="System.Drawing.Common" />
2526
</ItemGroup>
2627

2728
<ItemGroup>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
using LogExpert.UI.Controls.LogTabWindow;
1515
using LogExpert.UI.Dialogs;
1616
using LogExpert.UI.Extensions.Forms;
17+
using LogExpert.UI.Interface;
1718
using NLog;
1819
using WeifenLuo.WinFormsUI.Docking;
1920
//using static LogExpert.PluginRegistry.PluginRegistry; //TODO: Adjust the instance name so using static can be used.
2021

2122
namespace LogExpert.UI.Controls.LogWindow
2223
{
2324
//TODO: Implemented 4 interfaces explicitly. Find them by searcginh: ILogWindow.<method name>
24-
internal partial class LogWindow : DockContent, ILogPaintContext, ILogView, ILogWindow
25+
internal partial class LogWindow : DockContent, ILogPaintContextUI, ILogView, ILogWindow
2526
{
2627
#region Fields
2728

src/LogExpert.UI/Dialogs/BookmarkWindow.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@
44
using LogExpert.Core.Interface;
55
using LogExpert.UI.Entities;
66
using LogExpert.UI.Extensions.Forms;
7-
7+
using LogExpert.UI.Interface;
88
using NLog;
9-
10-
using System;
11-
using System.Collections.Generic;
12-
using System.Drawing;
13-
using System.Windows.Forms;
14-
159
using WeifenLuo.WinFormsUI.Docking;
1610

1711
namespace LogExpert.Dialogs;
@@ -25,7 +19,7 @@ public partial class BookmarkWindow : DockContent, ISharedToolWindow, IBookmarkV
2519
private readonly object paintLock = new();
2620

2721
private IBookmarkData bookmarkData;
28-
private ILogPaintContext logPaintContext;
22+
private ILogPaintContextUI logPaintContext;
2923
private ILogView logView;
3024

3125
#endregion
@@ -218,15 +212,15 @@ public void PreferencesChanged(Preferences newPreferences, bool isLoadTime, Sett
218212
PreferencesChanged(newPreferences, isLoadTime, flags, null);
219213
}
220214

221-
public void SetCurrentFile(FileViewContext ctx)
215+
public void SetCurrentFile(IFileViewContext ctx)
222216
{
223217
if (ctx != null)
224218
{
225219
_logger.Debug("Current file changed to {0}", ctx.LogView.FileName);
226220
lock (paintLock)
227221
{
228222
logView = ctx.LogView;
229-
logPaintContext = ctx.LogPaintContext;
223+
logPaintContext = (ILogPaintContextUI)ctx.LogPaintContext;
230224
}
231225

232226
SetColumnizer(ctx.LogView.CurrentColumnizer);

src/LogExpert.UI/Entities/PaintHelper.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using LogExpert.Core.Interface;
55
using LogExpert.Dialogs;
66
using LogExpert.UI.Controls;
7+
using LogExpert.UI.Interface;
78
using NLog;
89

910
namespace LogExpert.UI.Entities
@@ -29,7 +30,7 @@ internal static class PaintHelper
2930

3031
#region Public methods
3132

32-
public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridView gridView, int rowIndex,
33+
public static void CellPainting(ILogPaintContextUI logPaintCtx, BufferedDataGridView gridView, int rowIndex,
3334
DataGridViewCellPaintingEventArgs e)
3435
{
3536
if (rowIndex < 0 || e.ColumnIndex < 0)
@@ -293,12 +294,12 @@ public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBor
293294

294295
#region Private Methods
295296

296-
private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry)
297+
private static void PaintCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry)
297298
{
298299
PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry);
299300
}
300301

301-
private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry)
302+
private static void PaintHighlightedCell(ILogPaintContextUI logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HighlightEntry groundEntry)
302303
{
303304
object value = e.Value ?? string.Empty;
304305

0 commit comments

Comments
 (0)