Skip to content

Commit ac828f0

Browse files
authored
Merge pull request #395 from RandallFlagg/dll_import
DllImport - Solves #394
2 parents 2cc6b28 + 6911a07 commit ac828f0

22 files changed

Lines changed: 203 additions & 206 deletions

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/Config/ColorMode.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,5 @@ private static void SetBrightMode()
7474
InactiveTabColor = LessBrightBackgroundColor;
7575
DarkModeEnabled = false;
7676
}
77-
78-
#region TitleBarDarkMode
79-
[DllImport("dwmapi.dll")]
80-
private static extern int DwmSetWindowAttribute(nint hwnd, int attr, ref int attrValue, int attrSize);
81-
82-
private const int DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
83-
private const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
84-
85-
public static bool UseImmersiveDarkMode(nint handle, bool enabled)
86-
{
87-
88-
var attribute = DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
89-
if (IsWindows10OrGreater(18985))
90-
{
91-
attribute = DWMWA_USE_IMMERSIVE_DARK_MODE;
92-
}
93-
94-
int useImmersiveDarkMode = enabled ? 1 : 0;
95-
return DwmSetWindowAttribute(handle, attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
96-
97-
}
98-
99-
private static bool IsWindows10OrGreater(int build = -1)
100-
{
101-
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= build;
102-
}
103-
104-
#endregion TitleBarDarkMode
105-
10677
}
10778
}

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/Controls/LogWindow/TimeSpreadigControl.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
using LogExpert.Classes;
2-
using LogExpert.Core.Classes;
1+
using LogExpert.Core.Classes;
32
using LogExpert.Core.EventArguments;
4-
using LogExpert.UI.Controls.LogWindow;
3+
using LogExpert.UI.Extensions;
54
using NLog;
65

7-
using System;
8-
using System.Collections.Generic;
9-
using System.Drawing;
10-
using System.Windows.Forms;
11-
126
namespace LogExpert.UI.Controls.LogWindow
137
{
148
internal partial class TimeSpreadingControl : UserControl

0 commit comments

Comments
 (0)