Skip to content

Commit f3c021b

Browse files
committed
moving UI to Logexpert.UI for better maintainability
1 parent 83e40ac commit f3c021b

File tree

128 files changed

+6781
-6849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+6781
-6849
lines changed

src/LogExpert/Classes/Log/LogfileReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using LogExpert.Core.Classes.Log;
33
using LogExpert.Core.Classes.xml;
44
using LogExpert.Core.Entities;
5-
using LogExpert.Core.Entities.EventArgs;
5+
using LogExpert.Core.EventArgs;
66
using LogExpert.Core.Interface;
77

88
using NLog;

src/LogExpert/Classes/PaintHelper.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal class PaintHelper
3333

3434
#region Public methods
3535

36-
public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridView, int rowIndex,
36+
public static void CellPainting(ILogPaintContext logPaintCtx, BufferedDataGridView gridView, int rowIndex,
3737
DataGridViewCellPaintingEventArgs e)
3838
{
3939
if (rowIndex < 0 || e.ColumnIndex < 0)
@@ -122,7 +122,6 @@ public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridV
122122
}
123123
}
124124

125-
126125
public static DataGridViewTextBoxColumn CreateMarkerColumn()
127126
{
128127
DataGridViewTextBoxColumn markerColumn = new();
@@ -161,7 +160,7 @@ public static DataGridViewColumn CreateTitleColumn(string colName)
161160
return titleColumn;
162161
}
163162

164-
public static void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gridView)
163+
public static void SetColumnizer(ILogLineColumnizer columnizer, BufferedDataGridView gridView)
165164
{
166165
int rowCount = gridView.RowCount;
167166
int currLine = gridView.CurrentCellAddress.Y;
@@ -200,7 +199,7 @@ public static void SetColumnizer(ILogLineColumnizer columnizer, DataGridView gri
200199
//AutoResizeColumns(gridView);
201200
}
202201

203-
public static void AutoResizeColumns(DataGridView gridView)
202+
public static void AutoResizeColumns(BufferedDataGridView gridView)
204203
{
205204
try
206205
{
@@ -224,7 +223,7 @@ public static void AutoResizeColumns(DataGridView gridView)
224223
}
225224
}
226225

227-
public static void ApplyDataGridViewPrefs(DataGridView dataGridView, Preferences prefs)
226+
public static void ApplyDataGridViewPrefs(BufferedDataGridView dataGridView, Preferences prefs)
228227
{
229228
if (dataGridView.Columns.Count > 1)
230229
{
@@ -291,12 +290,12 @@ public static Rectangle BorderWidths(DataGridViewAdvancedBorderStyle advancedBor
291290

292291
#region Private Methods
293292

294-
private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, DataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry)
293+
private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry)
295294
{
296295
PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry);
297296
}
298297

299-
private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, DataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry)
298+
private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, BufferedDataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry)
300299
{
301300
object value = e.Value ?? string.Empty;
302301

src/LogExpert/Classes/TimeSpreadCalculator.cs

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using LogExpert.Classes.ILogLineColumnizerCallback;
22
using LogExpert.Controls.LogWindow;
3+
using LogExpert.Core.Classes;
34

45
using NLog;
56

@@ -10,7 +11,7 @@
1011

1112
namespace LogExpert.Classes
1213
{
13-
internal class TimeSpreadCalculator
14+
internal partial class TimeSpreadCalculator
1415
{
1516
#region Fields
1617

@@ -25,6 +26,7 @@ internal class TimeSpreadCalculator
2526
private readonly object _diffListLock = new();
2627
private readonly EventWaitHandle _lineCountEvent = new ManualResetEvent(false);
2728

29+
//TODO Refactor that it does not need LogWindow
2830
private readonly LogWindow _logWindow;
2931

3032
// for DoCalc_via_Time
@@ -211,12 +213,14 @@ private void DoCalc()
211213
{
212214
OnStartCalc(EventArgs.Empty);
213215
_logger.Debug("TimeSpreadCalculator.DoCalc() begin");
216+
214217
if (_callback.GetLineCount() < 1)
215218
{
216219
OnCalcDone(EventArgs.Empty);
217220
_logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1");
218221
return;
219222
}
223+
220224
int lineNum = 0;
221225
int lastLineNum = _callback.GetLineCount() - 1;
222226
_startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false);
@@ -231,6 +235,7 @@ private void DoCalc()
231235
_timePerLine = (int)Math.Round(overallSpanMillis / (double)_lineCount);
232236
DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false);
233237
int step;
238+
234239
if (_lineCount > _displayHeight)
235240
{
236241
step = (int)Math.Round(_lineCount / (double)_displayHeight);
@@ -245,6 +250,7 @@ private void DoCalc()
245250
List<SpreadEntry> newDiffList = [];
246251
List<TimeSpan> maxList = [];
247252
lineNum++;
253+
248254
for (int i = lineNum; i < lastLineNum; i += step)
249255
{
250256
int currLineNum = i;
@@ -259,11 +265,13 @@ private void DoCalc()
259265
_logger.Debug("TimeSpreadCalculator.DoCalc() time diff {0}", span);
260266
}
261267
}
268+
262269
if (maxList.Count > 3)
263270
{
264271
maxList.Sort();
265272
_maxSpan = maxList[^3];
266273
}
274+
267275
lock (_diffListLock)
268276
{
269277
DiffList = newDiffList;
@@ -280,12 +288,14 @@ private void DoCalc_via_Time()
280288
{
281289
OnStartCalc(EventArgs.Empty);
282290
_logger.Debug("TimeSpreadCalculator.DoCalc_via_Time() begin");
291+
283292
if (_callback.GetLineCount() < 1)
284293
{
285294
OnCalcDone(EventArgs.Empty);
286295
_logger.Debug("TimeSpreadCalculator.DoCalc() end because of line count < 1");
287296
return;
288297
}
298+
289299
int lineNum = 0;
290300
int lastLineNum = _callback.GetLineCount() - 1;
291301
_startTimestamp = _logWindow.GetTimestampForLineForward(ref lineNum, false);
@@ -296,8 +306,9 @@ private void DoCalc_via_Time()
296306
TimeSpan overallSpan = _endTimestamp - _startTimestamp;
297307
long overallSpanMillis = overallSpan.Ticks / TimeSpan.TicksPerMillisecond;
298308
//int timePerLine = (int)Math.Round((double)overallSpanMillis / (double)this.lineCount);
299-
DateTime oldTime = _logWindow.GetTimestampForLineForward(ref lineNum, false);
309+
300310
long step;
311+
301312
if (overallSpanMillis > _displayHeight)
302313
{
303314
step = (long)Math.Round(overallSpanMillis / (double)_displayHeight);
@@ -318,6 +329,7 @@ private void DoCalc_via_Time()
318329
_maxDiff = 0;
319330
List<int> maxList = [];
320331
List<SpreadEntry> newDiffList = [];
332+
321333
while (searchTimeStamp.CompareTo(_endTimestamp) <= 0)
322334
{
323335
lineNum = _logWindow.FindTimestampLine_Internal(lineNum, lineNum, lastLineNum, searchTimeStamp, false);
@@ -351,11 +363,13 @@ private void DoCalc_via_Time()
351363
oldLineNum = lineNum;
352364
//lineNum++;
353365
}
366+
354367
if (maxList.Count > 3)
355368
{
356369
maxList.Sort();
357370
_maxDiff = maxList[^3];
358371
}
372+
359373
_average = lineDiffSum / (double)loopCount;
360374
//double average = maxList[maxList.Count / 2];
361375
_logger.Debug("Average diff={0} minDiff={1} maxDiff={2}", _average, minDiff, _maxDiff);
@@ -383,9 +397,11 @@ private void DoCalc_via_Time()
383397
private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan)
384398
{
385399
DateTime oldTime = DateTime.MinValue;
400+
386401
if (DiffList.Count > 0)
387402
{
388403
oldTime = DiffList[0].Timestamp;
404+
389405
foreach (SpreadEntry entry in DiffList)
390406
{
391407
TimeSpan span = entry.Timestamp - oldTime;
@@ -401,6 +417,7 @@ private DateTime CalcValuesViaLines(int timePerLine, TimeSpan maxSpan)
401417
oldTime = entry.Timestamp;
402418
}
403419
}
420+
404421
return oldTime;
405422
}
406423

@@ -410,12 +427,14 @@ private void CalcValuesViaTime(int maxDiff, double average)
410427
{
411428
int lineDiff = entry.Diff;
412429
double diffFromAverage = entry.Diff - average;
430+
413431
if (diffFromAverage < 0)
414432
{
415433
diffFromAverage = 0;
416434
}
417435
int value = (int)(diffFromAverage / maxDiff * _contrast);
418436
entry.Value = 255 - value;
437+
419438
_logger.Debug("TimeSpreadCalculator.DoCalc() test time {0:HH:mm:ss.fff} line diff={1} value={2}", entry.Timestamp, lineDiff, value);
420439
}
421440
}
@@ -431,31 +450,5 @@ private void OnStartCalc(EventArgs e)
431450
}
432451

433452
#endregion
434-
435-
public class SpreadEntry
436-
{
437-
#region Fields
438-
439-
public int Diff { get; set; }
440-
441-
public DateTime Timestamp { get; set; }
442-
443-
public int LineNum { get; set; }
444-
445-
public int Value { get; set; }
446-
447-
#endregion
448-
449-
#region cTor
450-
451-
public SpreadEntry(int lineNum, int diff, DateTime timestamp)
452-
{
453-
LineNum = lineNum;
454-
Diff = diff;
455-
Timestamp = timestamp;
456-
}
457-
458-
#endregion
459-
}
460453
}
461454
}

src/LogExpert/Config/ConfigManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using LogExpert.Core.Classes.Filter;
33
using LogExpert.Core.Config;
44
using LogExpert.Core.Entities;
5-
using LogExpert.Core.Entities.EventArgs;
5+
using LogExpert.Core.EventArgs;
66

77
using Newtonsoft.Json;
88

src/LogExpert/Dialogs/DateTimeDragControl.Designer.cs renamed to src/LogExpert/Controls/DateTimeDragControl.Designer.cs

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

0 commit comments

Comments
 (0)